FriendsofED.AdvancED.ActionScript.Components.Mastering.the.Flash.Component.Architecture.Feb

AdvancED ActionScript
Components
Mastering the Flash Component Architecture

Antonio De Donatis

AdvancED ActionScript Components:
Mastering the Flash Component Architecture
Copyright © 2006 by Antonio De Donatis
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical,
including photocopying, recording, or by any information storage or retrieval system, without the prior written permission
of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-59059-593-0
ISBN-10 (pbk): 1-59059-593-9
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name,
we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of
infringement of the trademark.
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013.
Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit www.springeronline.com.
For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710.

Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit www.apress.com.
The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the
preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any
loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work.
The source code for this book is freely available to readers at www.friendsofed.com in the Downloads section.

Credits
Lead Editor
Chris Mills
Technical Reviewers
Sas Jacobs,
Paul Barnes-Hoggett
Editorial Board
Steve Anglin, Dan Appleman,
Ewan Buckingham, Gary Cornell,
Jason Gilmore, Jonathan Hassell,
James Huddleston, Chris Mills,
Matthew Moodie, Dominic Shakeshaft,
Jim Sumser, Matt Wade
Project Manager

Julie M. Smith
Copy Edit Manager
Nicole LeClerc
Copy Editors
Ami Knox, Marilyn Smith

Assistant Production Director
Kari Brooks-Copony
Production Editor
Laura Cheu
Compositor
Dina Quan
Proofreader
Christy Wagner
Indexer
Becky Hornyak
Cover Image Designer
Bruce Tang
Cover Designer
Kurt Krames

Manufacturing Director
Tom Debolski

To JenFeng

CONTENTS AT A GLANCE
About the Author

About the Technical Reviewers

. . . . . . . . . . . . . . . . . . . . . . . . . . .

About the Cover Image Designer
Acknowledgments
Introduction

xvii

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


xviii
xix

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

xxi

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

PART ONE INTRODUCING THE ARCHITECTURE
Chapter 1 OOP in Component Design

xx

. . . . . . . . . . .

1


. . . . . . . . . . . . . . . . . . . . . . . . .

3

Chapter 2 Core Classes and Component Design
Chapter 3 Exploring the UI Components

. . . . . . . . . . . . . . . .

33

. . . . . . . . . . . . . . . . . . . . .

59

Chapter 4 Building Component-based Applications

. . . . . . . . . . . . .

PART TWO EXPLOITING THE ARCHITECTURE


. . . . . . . . . . .

91

129

Chapter 5 Architecture-based Development

. . . . . . . . . . . . . . . . . .

131

Chapter 6 XML for Defining User Interfaces

. . . . . . . . . . . . . . . . . .

149

Chapter 7 Extending the Application Framework


. . . . . . . . . . . . . .

171

. . . . . . . . . . . . . . . . . . . . .

201

. . . . . . . . . . . . . . . . . . . . . . .

219

Chapter 8 Making Your XML Life Easier
Chapter 9 The Customization Process

iv

PART THREE CUSTOMIZING THE COMPONENTS
Chapter 10 The Accordion Component

Chapter 11 The Button Component

. . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

253

. . . . . . . . . . . . . . . . . . . . . . . . .

275

Chapter 12 The CheckBox and RadioButton Components

. . . . . . .

Chapter 13 The List, ComboBox, and DataGrid Components .

309


. . . . . . .

349

. . . . . . . . . . .

371

. . . . . . . . . . . . .

395

. . . . . . . . . . . . . . . . .

427

Chapter 15 The Loader, ScrollPane, and ProgressBar
Components . . . . . . . . . . . . . . . . . . . . . . .
Chapter 16 The Menu and MenuBar Components
Chapter 17 The NumericStepper Component


Chapter 18 The TextArea, TextInput, and Label Components

. . . .

439

. . . . . . . . . . . . . . . . . . . . . . . . . . .

459

Chapter 20 The Window and Alert Components
Chapter 21 Handling the Scrollbars

PART FOUR APPENDIXES

. . . . . . . . . . . . . .

483


. . . . . . . . . . . . . . . . . . . . . . . . .

507

. . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Appendix A Locating the Source Code of the Component
Architecture . . . . . . . . . . . . . . . . . . . . . . . . . .

521

. . . . . . .

523

. . . . . . . . . . . . . . . . . . .

529

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

535

Appendix B Transitions and Easing Classes
Index

295

. . . .

Chapter 14 The DateChooser and DateField Components

Chapter 19 The Tree Component

251

v

CONTENTS
About the Author

About the Technical Reviewers

. . . . . . . . . . . . . . . . . . . . . . . . . . .

About the Cover Image Designer
Acknowledgments
Introduction

xvii

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

xviii

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

PART ONE INTRODUCING THE ARCHITECTURE
Chapter 1 OOP in Component Design

xix
xx
xxi

. . . . . . . . . . .

1

. . . . . . . . . . . . . . . . . . . . . . . . .

3

A very short history of the architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Creating Flash components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
An apparently useless component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Creating the Vogon component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Adding a method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Variables, properties, and metadata tags . . . . . . . . . . . . . . . . . . . . . . . . . 8
Implementing a property explicitly . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Implementing a property implicitly . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Properties in the authoring environment . . . . . . . . . . . . . . . . . . . . . . 12
Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
A little help from Darwin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Appreciating the benefits of inheritance . . . . . . . . . . . . . . . . . . . . . . . . . 17
ActionScript limit on multiple inheritance . . . . . . . . . . . . . . . . . . . . . . . . 19
Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
What is an event in component terms? . . . . . . . . . . . . . . . . . . . . . . . . . 21
Implementing a custom event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Triggering a custom event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Listening to a custom event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Building the example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
And God took a rib from a Vogon . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
A method’s signature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Appreciating the benefits of polymorphism . . . . . . . . . . . . . . . . . . . . . . . 30
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

vi

Chapter 2 Core Classes and Component Design
The legacy of the UIObject class . . . . . . . . . . . . . .
Creating a component instance dynamically . . . . . .
Overriding the symbolName property . . . . . . .
Overriding the symbolOwner property . . . . . . .
Overriding the className property . . . . . . . .
The createClassObject method . . . . . . . . . . .
Our components join the architecture . . . . . . .
Inside the process of building a component instance
Step 1: Initialization . . . . . . . . . . . . . . . . . . .
Step 2: Creating the children . . . . . . . . . . . . . .
Step 3: Drawing the component instance . . . . . . .
Refining our sample components . . . . . . . . . . . . . .
The component framework . . . . . . . . . . . . . . . . .
The UIComponent class . . . . . . . . . . . . . . . . .
Accessibility/Keyboard use . . . . . . . . . . . . .
Other features of the UIComponent . . . . . . . .
The View class . . . . . . . . . . . . . . . . . . . . . .
The ScrollView class . . . . . . . . . . . . . . . . . . .
An ActionScript template for new components . . . .
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . .

Chapter 3 Exploring the UI Components
The Reusability Card . . . . . . . . .
Frequency (of use) . . . . . . . .
Complexity . . . . . . . . . . . .
Stability . . . . . . . . . . . . . .
Maturity . . . . . . . . . . . . . .
Popularity . . . . . . . . . . . . .
Multitier applications . . . . . . . . .
UI components provided with Flash
Button components . . . . . . .
Button component . . . . . .
CheckBox component . . . .
RadioButton component . .
Text components . . . . . . . . .
Label component . . . . . . .
TextInput component . . . .
TextArea component . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

33

. . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

59

. . . . . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

36
37
38
38
38
39
40
44
44
45
45
46
51
51
51
52
53
54
54
57

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

60
61
62
62
63
64
64
65
65
66
66
67
67
68
68
69

vii

CONTENTS

Cell-structured components . . .
List component . . . . . . . .
ComboBox component . . .
DataGrid component . . . .
Tree component . . . . . . .
Container components . . . . . .
ScrollPane component . . . .
Loader component . . . . . .
Window component . . . . .
Accordion component . . . .
Peculiar components . . . . . . .
Alert component . . . . . . .
DateChooser component . .
DateField component . . . .
Menu component . . . . . .
MenuBar component . . . .
NumericStepper component
ProgressBar component . . .
UIScrollBar component . . .
Using the UI components . . . . . .
A first example of interaction . .
Typical structure of a component . .
The actions layer . . . . . . . . .
The assets layer . . . . . . . . . .
The bounding box layer . . . . .
Summary . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

Chapter 4 Building Component-based Applications

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

. . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

69
70
70
71
72
72
73
74
74
75
76
76
77
78
78
79
80
80
81
82
82
85
87
87
88
88

91

Screens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Building an application using screens . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Content hierarchy in nested screens . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Reviewing the purpose of slides and forms . . . . . . . . . . . . . . . . . . . . . . . 96
Forms visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Conclusion: should you use slides or forms? . . . . . . . . . . . . . . . . . . . . 99
Screen hierarchies with external subtrees . . . . . . . . . . . . . . . . . . . . . . . . 99
The complete path to an external screen . . . . . . . . . . . . . . . . . . . . . 101
Creating a slide presentation dynamically . . . . . . . . . . . . . . . . . . . . . . . . . 102
Building the example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Importing the Slide class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Creating the screen hierarchy dynamically . . . . . . . . . . . . . . . . . . . . . 108
Adding navigation in the master screen . . . . . . . . . . . . . . . . . . . . . . 109
Implementing the buttons-based navigation . . . . . . . . . . . . . . . . . . . . 110
Using Loader components in the child screens . . . . . . . . . . . . . . . . . . 111
Introducing the transitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Importing the transition classes . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Screen events and transition sequencing . . . . . . . . . . . . . . . . . . . . . . 113
Working with forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

viii

CONTENTS

Manager classes . . . . . . . . . . . . . . . . . .
Managing depth . . . . . . . . . . . . . . . .
MovieClip methods for handling depth
A more flexible way of stacking objects
Testing the DepthManager behavior . .
Managing the keyboard focus . . . . . . . .
Defining a focus schema . . . . . . . . .
Setting a default button . . . . . . . . .
Tab order in a browser . . . . . . . . . .
Disabling the focus rect . . . . . . . . .
Managing windows . . . . . . . . . . . . . .
A simple window-based system . . . . .
Creating a window instance . . . . . . .
Experimenting with modal windows . .
Summary . . . . . . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

PART TWO EXPLOITING THE ARCHITECTURE
Chapter 5 Architecture-based Development
Exploiting the architecture . . . . . . . . . . . .
Key benefits of a component architecture .
What is your job, really? . . . . . . . . . . .
Raising the bar . . . . . . . . . . . . . . . . . . .
Extend, expand, and alter . . . . . . . . . .
Extending the architecture . . . . . . . .
Expanding the architecture . . . . . . .
Altering the architecture . . . . . . . . .
From abstract ideas to a concrete example
What is an XML layout engine? . . . . . . . . .
Benefits of an XML layout engine . . . . . .
Further benefits in the Flash context . . . .
XLEFF . . . . . . . . . . . . . . . . . . . . . . . .
XLEFF main features . . . . . . . . . . . . .
Beyond generating user interfaces . . . . .
XLEFF internal architecture . . . . . . . . . .
Summary . . . . . . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

. . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

131
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

132
132
133
134
134
134
136
137
137
138
138
140
140
144
144
145
146

149

. . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.

114
115
115
116
118
120
121
123
123
124
124
124
126
127
128

129

. . . . . . . . . . . . . . . . . .

Chapter 6 XML for Defining User Interfaces
Basics of the XML data structure
The Color Names section . . .
The Styles section . . . . . . .
Class styles . . . . . . . . .
Predefined styles . . . . .
Nested styles . . . . . . .
Custom styles . . . . . . .
The Stage section . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

150
151
151
152
153
153
154
155

ix

CONTENTS

XLEFF sampler . . . . . . . . . . . . . . . . . .
How to use it . . . . . . . . . . . . . . . .
Playing with the sampler . . . . . . . .
Examining a more complex user interface
User interface patterns . . . . . . . . .
A first look into the substructures . .
Using custom classes . . . . . . . . . .
Events to be handled . . . . . . . . . .
Summary . . . . . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

Chapter 7 Extending the Application Framework
Defining an FLA template . . . . . . . . . . . . . . . . .
Using scenes . . . . . . . . . . . . . . . . . . . . . . .
The Preloader scene . . . . . . . . . . . . . . . .
The Dynamic Assets scene . . . . . . . . . . . . .
The Main scene . . . . . . . . . . . . . . . . . . .
Licensing issue . . . . . . . . . . . . . . . . . . . . . .
Including the standard components source code
Progressive update of the template . . . . . . . .
Analyzing the size report . . . . . . . . . . . . . . . .
Moving the symbols after the first frame . . . . .
Moving the classes after the first frame . . . . .
Defining a folder structure . . . . . . . . . . . . . . . . .
The role of classpath . . . . . . . . . . . . . . . . . .
Facilitating event-driven programming . . . . . . . . . .
The Main class . . . . . . . . . . . . . . . . . . . . . .
A concrete example . . . . . . . . . . . . . . . . . .
Skeleton of the Main class . . . . . . . . . . . . .
Handling the user interface events . . . . . . . .
Event handler naming convention . . . . . . . .
Managing content . . . . . . . . . . . . . . . . . . . . . .
Pushing the separation paradigm further . . . . . . .
The role of CDATA . . . . . . . . . . . . . . . . .
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . .

Chapter 8 Making Your XML Life Easier

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

158
159
161
164
165
166
167
169
169

171

. . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

172
173
174
176
178
179
179
181
181
182
183
183
185
186
187
188
189
190
194
194
196
197
198

201

. . . . . . . . . . . . . . . . . . . . .

Parsing XML in ActionScript . . . . . . . . . . . . . .
Object models and trees . . . . . . . . . . . . . .
The typical job of an XML developer . . . . . . .
Simplifying the parsing process . . . . . . . . . . . .
Parsing an XML document . . . . . . . . . . . . .
Document root and other nodes . . . . . . .
Identifying a node name . . . . . . . . . . . .
Identifying a node type . . . . . . . . . . . . .
Accessing the attributes of a node . . . . . .
Browsing the structure of an XML document
A few notes on the use of XModel . . . . . . . . . .
Summary . . . . . . . . . . . . . . . . . . . . . . . . .

x

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

202
204
207
209
210
211
211
212
214
215
217
217

CONTENTS

Chapter 9 The Customization Process

219

. . . . . . . . . . . . . . . . . . . . . . .

Working with styles . . . . . . . . . . . . . . . . . . . .
Parameters controlled by styles . . . . . . . . . . .
The style lookup process . . . . . . . . . . . . . . .
Styles as properties of a component instance . . .
The styleName property . . . . . . . . . . . . . . .
Class-level styles . . . . . . . . . . . . . . . . . . . .
Inheriting styles from a container . . . . . . . . . .
Global styles . . . . . . . . . . . . . . . . . . . . . .
Analyzing skins . . . . . . . . . . . . . . . . . . . . . . .
What is a skin? . . . . . . . . . . . . . . . . . . . .
Handcrafted skins . . . . . . . . . . . . . . . . . . .
Mixed skins . . . . . . . . . . . . . . . . . . . . . .
Purely coded skins . . . . . . . . . . . . . . . . . .
Working with themes . . . . . . . . . . . . . . . . . . .
Changing skins and the mirage of code separation
Changing skins at authoring time . . . . . . . . . .
Changing skins programmatically . . . . . . . . . .
Skins that reflect styles . . . . . . . . . . . . . . . .
In search of a unified approach: subclassing . . . .
An alternative to subclassing . . . . . . . . . . . . .
Summary . . . . . . . . . . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

PART THREE CUSTOMIZING THE COMPONENTS
Chapter 10 The Accordion Component
A minimal example . . . . . . . . . . . . . . . . .
Code-based version . . . . . . . . . . . . . . .
Codeless version . . . . . . . . . . . . . . . .
XLEFF version . . . . . . . . . . . . . . . . . .
The component structure . . . . . . . . . . . . .
Segment header . . . . . . . . . . . . . . . . .
Segment content area . . . . . . . . . . . . .
A richer example . . . . . . . . . . . . . . . . . .
Codeless version . . . . . . . . . . . . . . . .
Code-based version . . . . . . . . . . . . . . .
Supported styles . . . . . . . . . . . . . . . . . . .
Common styles . . . . . . . . . . . . . . . . .
Specific styles . . . . . . . . . . . . . . . . . .
Skinnability . . . . . . . . . . . . . . . . . . . . . .
The border . . . . . . . . . . . . . . . . . . . .
The headers . . . . . . . . . . . . . . . . . . .
Solved mysteries . . . . . . . . . . . . . . . . . . .
Inheriting styles . . . . . . . . . . . . . . . . .
Creating header styles on a per-instance basis
Reasons for subclassing . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

. . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

251
253

. . . . . . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

220
221
221
222
223
225
226
227
228
228
228
231
234
236
236
237
240
243
245
249
249

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

254
255
256
257
257
258
258
259
259
261
262
263
265
265
265
266
268
268
271
273

xi

CONTENTS

Chapter 11 The Button Component

Minimal example of the Button component .
A richer example . . . . . . . . . . . . . .
Supported styles . . . . . . . . . . . . . . . . .
Common styles . . . . . . . . . . . . . . .
Specific styles . . . . . . . . . . . . . . . .
Halo theme case . . . . . . . . . . . .
Sample theme case . . . . . . . . . . .
Skinnability . . . . . . . . . . . . . . . . . . . .
Replacing the purely coded skin . . . . . .
The 32 skins of a button . . . . . . . . . .
Implementing a toggle button . . . . .
Emphasizing a button instance . . . .
Iconic buttons . . . . . . . . . . . . . .
Solved mysteries . . . . . . . . . . . . . . . . .
A purely coded classic: the pill button . .
Reasons for subclassing a Button component

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

Chapter 12 The CheckBox and RadioButton Components
Minimal example of the CheckBox and the RadioButton components . .
XLEFF version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Comparing the authoring parameters . . . . . . . . . . . . . . . . . . .
Supported styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Common styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Specific styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Skinnability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Solved mysteries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Where to find the RadioButtonGroup instance . . . . . . . . . . . . .
Reasons for subclassing the CheckBox and the RadioButton components

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

Minimal example including the List, ComboBox, and DataGrid components
XLEFF version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Richer examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Itemization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Custom labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Scrolling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Selection management . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Making it editable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Supported styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Common styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DataGrid-specific styles . . . . . . . . . . . . . . . . . . . . . . . . . . . .
List-specific styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ComboBox-specific styles . . . . . . . . . . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

296
297
297
298
298
300
302
305
305
307

309

. . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.

276
277
279
280
281
281
282
284
285
289
289
289
289
290
290
293

295

. . . . . . .

Chapter 13 The List, ComboBox, and DataGrid Components .

xii

275

. . . . . . . . . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.

310
313
314
315
317
320
323
327
331
333
336
336
337
337

CONTENTS

Skinnability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Solved mysteries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Cell rendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Building a custom cell renderer . . . . . . . . . . . . . . . . . . .
DataGrid column headers . . . . . . . . . . . . . . . . . . . . . .
The undefined item bug . . . . . . . . . . . . . . . . . . . . . . . . .
Reasons for subclassing the List, ComboBox, and DataGrid components

.
.
.
.
.
.
.

Chapter 14 The DateChooser and DateField Components
Minimal example of the DataChooser and DataField components . .
XLEFF version . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A richer example . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Code version . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
How to retrieve and set a date . . . . . . . . . . . . . . . . . . .
Ranges definition . . . . . . . . . . . . . . . . . . . . . . . . . . .
The scroll event . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Supported styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Common styles . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Specific styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Skinnability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Skinning the arrow buttons . . . . . . . . . . . . . . . . . . . . .
Skinning the DateField icon . . . . . . . . . . . . . . . . . . . . .
Solved mysteries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Displaying the date in custom format . . . . . . . . . . . . . . . .
A DateField bug . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Reasons for subclassing the DataChooser and DataField components

Chapter 15 The Loader, ScrollPane, and ProgressBar
Components . . . . . . . . . . . . . . . . . . . . . . .
Minimal examples . . . . . . . . . . . . . . . . . . . . .
A minimal example of the Loader component . . .
A minimal example of the ScrollPane component .
A minimal example of the ProgressBar component
The ProgressBar’s animated behavior . . . . . .
The indeterminate ProgressBar . . . . . . . . .
XLEFF versions . . . . . . . . . . . . . . . . . . . . .
Combined examples . . . . . . . . . . . . . . . . . . .
The ProgressBar communication modes . . . . . .
Codeless interaction . . . . . . . . . . . . . . . . .
ProgressBar and Loader interaction . . . . . . .
ProgressBar and ScrollPane interaction . . . . .
Mediated interaction . . . . . . . . . . . . . . . . .
Supported styles . . . . . . . . . . . . . . . . . . . . .
Skinnability . . . . . . . . . . . . . . . . . . . . . . . . .
Solved mysteries . . . . . . . . . . . . . . . . . . . . . .
Reasons for subclassing . . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

349

. . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

350
351
351
353
353
355
358
360
360
360
363
363
365
366
367
367
369

371

. . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

338
339
339
343
345
346
347

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

372
372
375
377
377
379
381
381
382
382
382
384
385
387
389
392
393

xiii

CONTENTS

Chapter 16 The Menu and MenuBar Components

Minimal examples . . . . . . . . . . . . . . . . . . . . . . . . . . .
Minimal example of the Menu component . . . . . . . . . . .
Minimal example of the MenuBar component . . . . . . . . .
Richer examples . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Generating richer menus by coding . . . . . . . . . . . . . . .
Generating richer menus using XML . . . . . . . . . . . . . .
XLEFF version . . . . . . . . . . . . . . . . . . . . . . . . . . .
Supported styles . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Stylizing the MenuBar (and its Menu instances) . . . . . . . .
Common styles . . . . . . . . . . . . . . . . . . . . . . . .
Specific styles . . . . . . . . . . . . . . . . . . . . . . . . .
Exploring the styles . . . . . . . . . . . . . . . . . . . . . .
Skinnability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Solved mysteries . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Further customization of a MenuBar skin . . . . . . . . . . .
Creating persistent Menu instances . . . . . . . . . . . . . . .
Reasons for subclassing the Menu and the MenuBar components

Chapter 17 The NumericStepper Component
Minimal example of the NumericStepper component . .
XLEFF version . . . . . . . . . . . . . . . . . . . . . .
Retrieving the value . . . . . . . . . . . . . . . . . . .
Minor bug for Flash MX 2004 users . . . . . . . .
Styles supported by the NumericStepper component . .
Skinning the NumericStepper component . . . . . . . .
Solved mysteries . . . . . . . . . . . . . . . . . . . . . . .
Reasons for subclassing the NumericStepper component

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

Minimal example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
XLEFF version of the minimal example . . . . . . . . . . . . . . . . .
How the Label component resizes automatically . . . . . . . . . . .
The text field inside . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Richer example of the TextInput and TextArea components . . . . . . .
Handling the input process . . . . . . . . . . . . . . . . . . . . . . .
Supported styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Note on the skins . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Solved mysteries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Hiding the background . . . . . . . . . . . . . . . . . . . . . . . . . .
Handling the combination linefeed/CR . . . . . . . . . . . . . . . . .
Reasons for subclassing the Label, TextInput, and TextArea components

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

428
429
429
431
431
433
435
437

439

. . . .

.
.
.
.
.
.
.
.
.
.
.
.

396
396
398
399
399
405
408
409
409
409
410
410
414
417
417
420
424

427

. . . . . . . . . . . . . . . . .

Chapter 18 The TextArea, TextInput, and Label Components

xiv

395

. . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.

440
442
442
445
446
446
448
450
450
451
453
456

CONTENTS

Chapter 19 The Tree Component

Minimal example of the Tree component . . . . . .
XLEFF version of the minimal example . . . . . .
Supported styles . . . . . . . . . . . . . . . . . . . . .
Color styles . . . . . . . . . . . . . . . . . . . . .
Text styles . . . . . . . . . . . . . . . . . . . . . .
Animation styles . . . . . . . . . . . . . . . . . . .
Icon styles . . . . . . . . . . . . . . . . . . . . . .
Other component-specific styles . . . . . . . . .
A note on skins . . . . . . . . . . . . . . . . . . .
Stylizing the minimal example . . . . . . . . . . .
Solved mysteries . . . . . . . . . . . . . . . . . . . . .
Taking full control . . . . . . . . . . . . . . . . . .
Implementing isBranch and other XML attributes
Reasons for subclassing the Tree component . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

Chapter 20 The Window and Alert Components
Minimal example of the Window and Alert components . .
Dynamically creating windows . . . . . . . . . . . . . . .
Dynamically creating alerts . . . . . . . . . . . . . . . . .
Managing the content of a Window instance . . . . . . . . .
Supported styles . . . . . . . . . . . . . . . . . . . . . . . . .
Skinning the Window and Alert components . . . . . . . . .
Skin properties of the Window component . . . . . . .
Skin properties of the Alert component . . . . . . . . .
Adding skins to our previous stylized example . . . . . .
Reasons for subclassing the Window and Alert components

Chapter 21 Handling the Scrollbars

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

484
487
489
490
495
499
499
500
500
505

507
.
.
.
.
.

508
510
510
512
519

521
523

. . . . . . .

.
.
.
.

460
464
465
466
466
466
467
467
467
468
470
471
477
480

483

. . . . . . . . . . . . . . . . . . . . . . . . .

Appendix A Locating the Source Code of the Component
Architecture . . . . . . . . . . . . . . . . . . . . . . . . . .
If you are a Windows user
If you are a Mac user . . .
FLA source files . . . . . .
Link them . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.

. . . . . . . . . . . . . .

Minimal example of the UIScrollBar component . . . . . . . . . . .
Customizing the scrollbars inside a component . . . . . . . . . . .
Step 1: Building a stylized version of the DataGrid component
Step 2: Skinning the scrollbars . . . . . . . . . . . . . . . . . . .
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

PART FOUR APPENDIXES

459

. . . . . . . . . . . . . . . . . . . . . . . . . . .

.
.
.
.

524
525
525
526

xv

CONTENTS

Appendix B Transitions and Easing Classes
Parameters common to all of the transition types
Easing classes . . . . . . . . . . . . . . . . . .
Transition-specific parameters . . . . . . . . . . .
The Blinds transition . . . . . . . . . . . . . .
The Fly transition . . . . . . . . . . . . . . . .
The Iris transition . . . . . . . . . . . . . . . .
The PixelDissolve transition . . . . . . . . . .
The Rotate transition . . . . . . . . . . . . . .
The Squeeze transition . . . . . . . . . . . . .
The Wipe transition . . . . . . . . . . . . . . .
Example of a transition parameters object . . . .

Index

xvi

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

529

. . . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.

530
531
532
532
532
532
532
532
533
533
533

535

ABOUT THE AUTHOR
Antonio De Donatis, who graduated in Computer Science from Pisa
University, has been designing and implementing object-oriented software since 1989, seems like a lifetime, when the first OOP developing
tools appeared on the market. So far Antonio has managed, designed,
and in several cases single-handedly implemented numerous projects
for a variety of industries, ranging from media/communications to
pharmaceuticals.
Antonio has worked for both large corporations and leading new
media agencies, and currently trades under the name of Managed
Source Limited, based in Surrey, England, where he has lived since
1998 after moving from Italy, his native country.
His commercial experience with Flash goes back to the fourth version of the software, released in
1999. In recent years, the object-oriented evolution of ActionScript has allowed him to reuse knowledge and techniques that he mastered when utilizing older programming languages such as C++
and Java.
Antonio is a specialist in the design of component-based architectures for the implementation of
knowledge and content management systems and is now working on several projects, including the
open source XML layout engine for Flash mentioned in this book, the latest version of which can be
downloaded from www.xleff.org.
Antonio considers programming a form of art and also enjoys chess, painting, and photography.

xvii

ABOUT THE TECHNICAL REVIEWERS
Sas Jacobs is a web developer who loves working with Flash. She set up her business, Anything Is
Possible, in 1994, working in the areas of web development, IT training, and technical writing. The
business works with large and small clients building web applications with ASP.NET, Flash, XML, and
databases. Sas has spoken at such conferences as Flash Forward, MXDU, and FlashKit on topics
relating to XML and dynamic content in Flash. She is the author of the book Foundation XML for
Flash (friends of ED, 2005) and contributed two chapters to Object-Oriented ActionScript for Flash 8
(friends of ED, 2006).
After studying architecture for seven years, Paul Barnes-Hoggett changed his mind and decided to
spend his time designing the “intergoogle.” He spent time as a lead developer at boxnewmedia,
where he built award-winning sites for clients such as Select Model Management. (In his own words,
he admits, “It’s a tough job looking at pictures of beautiful people all day, but someone has to do
it.”) He set up Eyefodder in 2003, which specializes in building rich Internet applications for the
media industry, and has built solutions for clients including FHM, Adidas, Air Miles, and ITV.
When not pushing pixels, Paul likes to eat, drink, and be merry. To get in contact with him, visit
www.eyefodder.com.

xviii

ABOUT THE COVER IMAGE DESIGNER
Bruce Tang is a freelance web designer, visual programmer, and author from Hong Kong. His main
creative interest is generating stunning visual effects using Flash or Processing.
Bruce has been an avid Flash user since Flash 4, when he began using Flash to create games, websites, and other multimedia content. After several years of ActionScripting, he found himself
increasingly drawn toward visual programming and computational art. He likes to integrate math
and physics into his work, simulating 3D and other real-life experiences onscreen. His first Flash
book was published in October 2005. Bruce’s folio, featuring Flash and Processing pieces, can be
found at www.betaruce.com, and his blog at www.betaruce.com/blog.
The cover image uses a high-resolution Henon phase diagram generated by Bruce with Processing,
which he feels is an ideal tool for such experiments. Henon is a strange attractor created by iterating through some equations to calculate the coordinates of millions of points. The points are then
plotted with an assigned color.
xn+1 = xn cos(a) - (yn - xnp) sin(a)
yn+1 = xn sin(a) + (yn - xnp) cos(a)

xix

ACKNOWLEDGMENTS
I would like to thank every member of the team involved in this project—Chris Mills for sharing the
ambitious vision of this book since its inception; Julie Smith for her essential help in coordinating
and controlling the disparate processes that have made this book possible; Sam Robbins, Sas Jacobs,
and P

Dokumen yang terkait