User Guide
4Contents
Advanced topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Example: GeometricShapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Chapter 5: Display Programming . . . . . . . . . . . . . . . . . . . . . . . . . 159
Understanding the display architecture . . . . . . . . . . . . . . . . . . . . . . . . . 160
Working with display objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Basics for working with the core display classes . . . . . . . . . . . . . . . . . 176
Example: SpriteArranger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
PART 2: CORE ACTIONSCRIPT 3.0 DATA TYPES AND CLASS-
ES
Chapter 6: Working with Dates and Times . . . . . . . . . . . . . . . . . 197
Managing calendar dates and times . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Controlling time intervals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Example: Simple analog clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Chapter 7: Working with Strings . . . . . . . . . . . . . . . . . . . . . . . . 209
Creating strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
The length property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211
Working with characters in strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211
Comparing strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
Obtaining string representations of other objects . . . . . . . . . . . . . . . . 213
Concatenating strings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Finding substrings and patterns in strings . . . . . . . . . . . . . . . . . . . . . . . 214
Converting strings between uppercase and lowercase . . . . . . . . . . . 219
Example: ASCII Art . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Chapter 8: Working with Arrays . . . . . . . . . . . . . . . . . . . . . . . . . 227
Indexed arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .227
Associative arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .236
Multidimensional arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Cloning arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243
Advanced Topics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243
Example: PlayList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Chapter 9: Handling Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Types of errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .256
Error handling in ActionScript 3.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .258
Working with the debugger version of Flash Player . . . . . . . . . . . . . 260