User Guide

4Contents
Chapter 8: Creating Advanced MXML Components . . . . . . . . . . 91
About reusable MXML components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Adding custom properties and methods to a component . . . . . . . . . . 92
Working with events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
About interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114
PART 3: CREATING ACTIONSCRIPT COMPONENTS
Chapter 9: Creating Simple Visual Components in ActionScript . .
121
About ActionScript components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121
Adding properties and methods to a component . . . . . . . . . . . . . . . . . 125
Defining events in ActionScript components . . . . . . . . . . . . . . . . . . . . 140
Applying styles to custom components . . . . . . . . . . . . . . . . . . . . . . . . . 144
Chapter 10: Creating Advanced Visual Components in
ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
About creating advanced components. . . . . . . . . . . . . . . . . . . . . . . . . . 147
Implementing the component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Making components accessible. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Adding version numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Best practices when designing a component . . . . . . . . . . . . . . . . . . . . 172
Example: Creating a composite component . . . . . . . . . . . . . . . . . . . . . 172
Troubleshooting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Chapter 11: Creating Custom Style Properties . . . . . . . . . . . . . . 183
About styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Example: Creating style properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Chapter 12: Creating Template Components . . . . . . . . . . . . . . . 195
About template components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Implementing a template component . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
PART 4: CREATING NONVISUAL FLEX COMPONENTS
Chapter 13: Creating Custom Formatters . . . . . . . . . . . . . . . . . 207
Creating a custom formatter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Using the SwitchSymbolFormatter class. . . . . . . . . . . . . . . . . . . . . . . . .211
Extending a Formatter class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214