ActionScript: The Definitive Guide
Table of Contents
Last Updated: January 13, 2001
- Foreword (by Gary Grossman)
- Preface
Part I: ActionScript Fundamentals
1) A Gentle Introduction for Non-Programmers
- Some Basic Phrases
- Creating Code
- Say Hi to Flash
- Keeping Track of Things (a.k.a. Variables)
- The Wizard Behind the Curtain (a.k.a. the Interpreter)
- Extra Info Required (a.k.a. Arguments)
- ActionScript Glue (a.k.a. Operators)
- Putting It All Together
- Further ActionScript Concepts
- Flash programs
- Script Data (a.k.a. Expressions)
- Two Vital Statement Types: Conditionals and Loops
- Modular Code (a.k.a. Functions)
- Movie Clip Instances
- The Event-Based Execution Model
- Building A Multiple-Choice Quiz
- Quiz overview
- Build The Layer Structure
- Create The Interface And Questions
- Initialize The Quiz
- Add Frame Labels
- Scripting The Answer Buttons
- Build The Quiz End
- Try It Out
2) Variables
- Creating Variables (a.k.a. Declaration)
- Automatic Variable Creation
- Legal Variable Names
- Declare Variables At The Outset
- Setting Variable Values (a.k.a. Assignment)
- Changing and Retrieving Variable Values
- Checking if a Variables Has No Value
- Types of Values
- Auotmatic Typing
- Automatic Value Conversion
- Determining The Type Manually
- Variable Scope
- When And Where Variables Are Accessible
- Movie Clip Variables
- Accessing Variables On Different Timelines
- Movie Clip Variable Life Span
- Local Variables
- Some Applied Examples
3) ActionScript Data and Data Types
- Data Versus Information
- Retaining Meaning with Data Types
- The ActionScript Data Types
- Creating and Categorizing Data
- Automatic Literal Typing
- Automatic Complex Expression Typing
- Data-Type Conversion
- Automatic Type Conversion
- Explicit Type Conversion
- Conversion Duration
- Flash 4 to Flash 5 Data-Type Conversion
- Determining the Type of An Existing Datum
- Primitive Data versus Composite Data
4) Primitive Data Types
- The Number Type
- Integers and Floating-Point Numbers
- Numeric Literals
- Integer Literals
- Floating-point Literals
- Special Values of the Number Data Type
- Working with Numbers
- Using Operators
- Built-in Mathematical Functions
- The String Type
- Character Encoding
- String Literals
- The empty string
- Escape sequences
- Unicode Escape Sequences
- Working with Strings
- Joining strings together
- Comparing Strings
- Using Built-In String Functions
- Character Indexing
- Examining Strings
- Retrieving Portions of Strings
- Combining String Examination with Substring Extraction
- Character Case Conversion
- Character Code Functions
- Executing Code in a String with Eval
- Reference: Flash 4 vs Flash 5 String Operators and Functions
- The Boolean Type
- Using Boolean Values to Build a Preloader
- Undefined
- Null
5)Operators
- General Features of Operators
- Operators and Expressions
- Number of Operands
- Operator Precedence
- Operator Associativity
- Data Types and Operators
- The Assignment Operator: =
- Combining Operations with Assignment
- Arithmetic Operators
- Addition: +
- Increment: ++
- Subtraction: -
- Decrement: --
- Multiplication: *
- Division: /
- Modulo: %
- Unary Negation: -
- The Equals Operator: ==
- Primitive Data Type Equality
- Composite Data Type Equality
- Equality and Data Type Conversion
- The Does-Not-Equal Operator: !=
- Common Uses of Equality Operations
- The Comparison Operators
- The Less-than Operator:
- The Greater-than Operator:
- The Less-than-or-equal Operator: <=
- The Greater-than-or-equal Operator: >=
- Comparison Operations and Data Type Conversion
- The String Operators
- The Logical Operators
- Logical OR: ||
- Logical AND:
- Logical NOT: !
- Logical Expressions and Data Values
- The Grouping Operator: ()
- The Comma Operator
- The void Operator
- The Bitwise Operators
- Other Operators
- The typeof Operator
- The new Operator
- The delete Operator
- The Array-Element/Object-Property Access Operator: []
- The Dot Operator
- The Conditional Operator: ? :
- The Function Call Operator: ()
6) Statements
- Types of Statements
- Statement Syntax
- Statement Blocks
- The ActionScript Statements
- Loops and Conditionals
- Expression Statements
- The var Statement
- The set Statement (aka Set Variable)
- The function Statement
- Function Call Statements
- The call Statement
- The return Statement
- The with Statement
- The ifFrameLoaded Statement
- The Empty Statement
- Statements versus Actions
7) Conditionals
- The if Statement
- The else Statement
- TheConditional Operator
- The else if Statement
- Simulating the switch Statement
- Compact Conditional Syntax
8) Loops
- The while Statement
- Loop Terminology
- The do-while Statement
- The for Statement
- Multiple Iterators in for Loops
- The for-in Statement
- Stopping a Loop Prematurely
- The break Statement
- The continue Statement
- Maximum Number of Iterations
- Timeline and Clip Event Loops
- Creating An Empty-Clip Timeline Loop
- Flash 5 Clip Event Loops
- Frame Rate’s Effect on Timeline Loops and Clip Event Loops
9) Functions
- Creating Functions
- Running Functions
- Passing Information to Functions
- Creating Functions with Parameters
- Invoking Functions with Parameters
- Exiting and Returning Values from Functions
- Terminating a Function
- Returning Values from Functions
- Function Literals
- Function Availability and Life Span
- Function Availability
- Function Life Span
- Function Scope
- The Scope Chain
- Local Variables
- Function Parameters Revisited
- Number of Parameters
- The arguments Object
- Primitive versus Composite Parameter Values
- Recursive Functions
- Internal Functions
- Internal Function Availability
- Functions As Objects
- Passing Functions to Functions
- Centralizing Code
- The Multiple-Choice Quiz Revisited
10) Events and Event Handlers
- Synchronous Code Execution
- Event-Based Asynchronous Code Execution
- Types of Events
- Event Handlers
- Event Handler Syntax
- Creating Event Handlers
- Attaching Event Handlers to Buttons and Movie Clips
- Attaching Event Handlers to Other Objects
- Event Handler Scope
- Movie Clip Event Handler Scope
- Button Event Handler Scope
- Other Object Event Handler Scope
- Button Events
- press
- release
- releaseOutside
- rollOver
- rollOut
- dragOut
- dragOver
- keyPress
- Movie Clip Events
- enterFrame
- load
- unload
- data
- The User-Input Movie Clip Events
- mouseDown
- mouseUp
- mouseMove
- keyDown
- keyUp
- Order of Execution
- Copying Clip Event Handlers
- Refreshing the Screen with updateAfterEvent
- Code Reusability
- Dynamic Movie Clip Event Handlers
- Event Handlers Applied
11) Arrays
- What is an Array?
- The Anatomy of an Array
- Array Elements
- Array Element Indexing
- Array Size
- Creating Arrays
- The Array Constructor
- Array Literals
- Referencing Array Elements
- Retrieving an Element's Value
- Setting an Element's Value
- Determining the Size of an Array
- Named Array Elements
- Creating and Referencing Named Array Elements
- Removing Named Elements
- Adding Elements to an Array
- Adding New Elements Directly
- Adding New Elements with the length Property
- Adding New Elements with Array Methods
- Removing Elements from an Array
- Removing Elements with the delete Operator
- Removing Elements with the length Property
- Removing Elements with Array Methods
- General Array-Manipulation Tools
- The reverse Method
- The sort Method
- The slice Method
- The join Method
- The toString Method
- Arrays as Objects
- Multi-dimensional Arrays
- The Multiple-Choice Quiz, Take 3
12) Objects and Classes
- The Anatomy of an Object
- Instantiating Objects
- Object Properties
- Referring to Properties
- Using a for-in Loop to Access an Object's Properties
- Methods
- Classes and Object-Oriented Programming
- Object Classes
- Making A Class
- Object Property Inheritance
- Superclasses and Subclasses
- Object-Oriented Programming Summary
- The Built-in Classes and Objects of ActionScript
- Built-in Classes
- Built-in Objects
- Learning the Ropes
13) Movie Clips
- The "Objectness" of Movie Clips
- Types of Movie Clips
- Main Movies
- Regular Movie Clips
- Smart Clips
- Process Clips
- Script Clips
- Linked Clips
- Seed Clips
- Creating Movie Clips
- Movie Clip Symbols and Instances
- Creating Instances
- Instance Names
- Importing External Movies
- Movie and Instance Stacking Order
- The Internal Layer Stack
- The Programmatically Generated Clip Stack
- The .swf Document "_level" Stack
- Stacks and Order of Execution
- Referring to Instances and Main Movies
- Using Instance Names
- Referring to the Current Instance or Movie
- Referring to Nested Instances
- Referring Main Movies with _root and _level
- Authoring Instance References with Insert Target Path
- Dynamic References to Clip Objects
- Whither Tell Target?
- Removing Movie Clip Instances and Main Movies
- Using unloadMovie with Instances and Levels
- Using removeMovieClip to Delete Instances
- Removing Manually Created Instances Manually
- Built-in Movie Clip Properties
- What, No _color Property?
- Movie Clip Methods
- Creating Movie Clip Methods
- Invoking Movie Clip Methods
- Built-in Movie Clip Methods
- Applied Movie Clip Examples
- Build a Clock with Clips
- The Last Quiz
14) Lexical Structure
- Whitespace
- Statement Terminators (aka Semicolons)
- Comments
- Reserved Words
- Identifiers
- Case Sensitivity
15) Advanced Topics
- Copying, Comparing, and Passing Data
- Bitwise Programming
- Bitwise AND: &
- Bitwise OR: |
- Bitwise XOR: ^
- Bitwise NOT: ~
- The Bitwise Shift Operators: >, <, >
- Bitwise Operations Applied
- Advanced Function Scope Issues
- The movieclip Data Type
PART II: Applied Actionscript
16) Using the Authoring Environment
- The Actions Panel
- Editing Modes
- Adding Scripts to Frames
- Adding Scripts to Buttons
- Adding Scripts to Movie Clips
- Where’s All the Code?
- Productivity
- Externalizing ActionScript Code
- Import From File (Author-Time Import)
- #include (Compile-Time Import)
- Shared library (Run-Time Import)
- Packaging Components as Smart Clips
- Building a Smart Clip with a Standard Interface
- Building a Smart Clip with a Customized Interface
- Using Smart Clips
17) Flash Forms
- The Flash Form Data-Cycle
- Flash Client-Side User Input
- Transmitting Data for Server-Side Processing
- The Data-handling Application
- Flash Receives and Interprets Results
- Creating a Flash Fill-in Form
- Building the Front End
- Sending Data to the Server
- The PERL Script, echo.pl
- Receiving Results from the Server
18) On-screen Text Fieds
- Dynamic Text Fields
- Creating a Dynamic Text Field
- Changing the Content of a Dynamic Text Field
- Retrieving the Value of a Dynamic Text Field
- User Input Text Fields
- Creating a User Input Text Field
- Changing the Content of an Input Text Field
- Retrieving and Using the Value of an Input Text Field
- User Input Text Fields and Forms
- Text Field Options
- Line Display
- Variable
- Border/Bg
- Word Wrap
- Selectable
- Max Characters
- Embed Fonts
- Text Field Properties
- The scroll Property
- The maxscroll Property
- Typical Text-Scrolling Code
- HTML Support
- <B> (bold)
- <I> (italics)
- <U> (underline)
- <FONT> (font control)
- <P> (Paragraph break)
- <BR> (Line break)
- <A> (Anchor or Hypertext Link)
- Anchor Tag Tab Order
- Quoting Attribute Values
- Unrecognized Tags and Attributes
- Using HTML as Output
- Using HTML as Input
- Executing JavaScript from HTML Links
- Calling ActionScript Functions from HTML Links
- Working with Text Field Selections
- Empty Text Fields and the for-in Statement
19) Debugging
- Debugging Tools
- The trace Function
- The List Variables Command
- The List Objects Command
- The Bandwidth Profiler
- The Debugger
- Debugging Methodology
- Recognizing Bugs
- Identifying the Source of a Bug
- Fixing Bugs
PART III: Language Reference
- Alphabetical Listing of Global Functions, Global Properties, Classes, and Objects
Appendices
Appendix A: Resources
Appendix B: Latin 1 Character Repertoire and Key Codes
Appendix C: Backwards Compatibility
Appendix D: Differences Between ECMA-262, JavaScript, and ActionScript