User Guide
4 Contents
Behaviors conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Screens conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Video conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Performance and Flash Player . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Guidelines for Flash applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Projects and version control guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Guidelines for accessibility in Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Advertising with Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
CHAPTER 4: Writing and Debugging Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Controlling when ActionScript runs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Using the Actions panel and Script window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Using the ActionScript editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Unicode support for ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Debugging your scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Using the Output panel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Updating Flash Player for testing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
CHAPTER 5: Handling Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Using event handler methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Using event listeners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Using button and movie clip event handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Broadcasting events from component instances . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Creating movie clips with button states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Event handler scope. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Scope of the this keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
CHAPTER 6: Creating Interaction with ActionScript . . . . . . . . . . . . . . . . . . . . . 179
About events and interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Controlling SWF file playback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Creating interactivity and visual effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Deconstructing a sample script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
CHAPTER 7: Using the Built-In Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
About classes and instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Overview of built-in classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
CHAPTER 8: Working with Movie Clips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
About controlling movie clips with ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . 205
Calling multiple methods on a single movie clip . . . . . . . . . . . . . . . . . . . . . . . . . 206
Loading and unloading additional SWF files. . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Specifying a root Timeline for loaded SWF files . . . . . . . . . . . . . . . . . . . . . . . . . 208
Loading JPEG files into movie clips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Changing movie clip position and appearance. . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Dragging movie clips. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Creating movie clips at runtime. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211