You are previewing ActionScript 3.0: Visual QuickStart Guide.
O'Reilly logo
ActionScript 3.0: Visual QuickStart Guide

Book Description

ActionScript is the programming language integral to the Adobe Technology Platform. It began as a simple scripting language for creating interactivity and animation in Flash, but is now used to create full-featured Web applications, not only in Flash but in Flex. ActionScript 3, introduced with Flex 2, is now a full-fledged object-oriented programming language, and the need for teaching materials, for both newcomers and veterans, is great. This task-based tutorial is for students with no programming experience as well as those programmers who have learned earlier versions of the programming language and now need to learn the new version. The book walks a reader through all the fundamentals, then moves on to creating interactivity, working with data, looping and decision making, programming visualizations, and working with multimedia. It's a complete end-to-end tutorial.

Table of Contents

  1. Copyright
    1. Dedication
  2. Special Thanks to
  3. Foreword
  4. Introduction
    1. Is ActionScript 3 for you?
    2. What’s in this book?
    3. Resources
    4. What’s next?
  5. 1. Introduction to ActionScript 3
    1. The Language of ActionScript
      1. Classes and objects
      2. Objects
      3. Classes
    2. ActionScript Syntax
      1. Dot syntax
    3. Punctuation
      1. Semicolon
      2. Parentheses
      3. Curly braces
      4. Commas
    4. About Classes and Objects
      1. What is an object?
      2. Instantiating an object of the MovieClip class
    5. Writing ActionScript
      1. To open and set up the Actions panel
      2. Using the trace() statement
      3. To trace a value to the Output panel
      4. Using comments
      5. To add comments to your script
      6. Setting ActionScript preferences
        1. To set ActionScript preferences
  6. 2. Working with Variables and Properties
    1. What Is a Variable?
      1. Naming variables
      2. Naming conventions
    2. Declaring and Assigning Values to Variables
      1. To declare a variable, and assign and display its value
    3. Data Typing Variables
      1. To data type variables
    4. Working with Strings
      1. Strings
      2. Combining strings
        1. To combine strings together
      3. Appending a value to a string
        1. To append a value to a string
      4. Escape sequences
        1. To add commands in strings using escape sequences
    5. Working with Numbers
      1. Working with math
        1. To perform basic arithmetic
      2. Using compound operators
        1. To perform math using compound operators
      3. Number data types
    6. Data Type Conversions
      1. To convert a variable data type
    7. Instances and Properties
      1. Instances
      2. Properties
        1. To set a MovieClip’s properties with ActionScript
    8. About Booleans
  7. 3. Working with Functions and Methods
    1. Methods and Functions
      1. Methods
        1. To call methods of the MovieClip class
      2. Functions
      3. Defining a function
        1. To write and call your own function
      4. Using arguments and parameters with functions
        1. To use arguments and parameters in a function
        2. To pass variables as arguments to a function
    2. Returning Values from a Function
      1. Setting a function’s return type
        1. To return type a function
        2. Return typing functions that do not return values
    3. Function Scope
      1. To practice using function scope
  8. 4. Working with Classes and Objects
    1. Defining Classes and Objects
    2. Importing a Class
      1. To import classes
    3. Instantiating Objects
      1. To instantiate an object
      2. Object methods
        1. To call methods of an object
      3. Object properties
        1. To set properties of an object
      4. Data-typing object instances
        1. To data-type an object instance
    4. Working with External Code
      1. To create an external .as file
      2. To include an ActionScript file
  9. 5. Display Lists and Display Objects
    1. The Display List
      1. Adding objects to the display list
    2. Display Classes and Objects
      1. Display objects
        1. To add a StaticText display object to the display list at authortime
      2. Interactive objects
        1. To add an interactive object to the display list from the library at runtime
        2. To instantiate and add an interactive object to the display list at runtime
      3. Display object containers
      4. The MovieClip class
        1. To add a display object container from the library with ActionScript at runtime
        2. To add a child object to a MovieClip display object container
        3. To instantiate and add a display object container with ActionScript at runtime
  10. 6. Working with Display Objects
    1. Display Object Properties
      1. To set the properties of MovieClip display objects with ActionScript
      2. Positioning display objects dynamically
        1. To dynamically position display objects
      3. Positioning and registration points
        1. To experiment with display object properties using different registration points
      4. Using display object containers to position groups of display objects
        1. To group display objects in a display object container
    2. Managing Object Depths
      1. To manage DisplayObject depths
    3. Removing Display Objects from the Display List
      1. To remove a DisplayObject from the display list
  11. 7. Communication and Events
    1. The ActionScript 3 Event Model
      1. Event process details
      2. Event dispatchers
      3. Registering event listeners
      4. Event listeners
    2. Working with Event Listeners
      1. The Event class
        1. To listen for an event of the Event class
        2. To listen for multiple event types of the Event class
      2. Working with event objects
        1. To access the properties of an event object
      3. The MouseEvent class
        1. To listen for mouse events
      4. Checking for multiple event types in the same event handler
        1. To check for multiple event types in an event listener
      5. The KeyboardEvent class
        1. To detect keyboard events and key values
      6. Removing event listeners
        1. To remove an event listener
    3. Event Flow
      1. To work with the event flow
    4. Subclasses of the Event Class
  12. 8. Controlling the Timeline
    1. Controlling Timelines
      1. To stop the timeline
      2. To play the timeline
      3. To navigate to frames on the timeline
      4. Using frame labels
        1. To make buttons with MovieClips and frame labels
    2. Navigating Timelines with Target Paths
      1. Absolute and relative target paths
        1. To control timelines with target paths
    3. Declaring the Frame Rate at Runtime
      1. To change the frame rate with ActionScript
  13. 9. Working with Strings
    1. The String Class
      1. Escaped characters
        1. To use escape sequences in strings
    2. Combining Strings
      1. To combine strings
      2. Converting nonstrings to strings
        1. To recast values as strings
    3. Manipulating Strings
      1. To obtain a substring of a string variable
      2. Separating delineated values in a string
        1. To split a string of values using a common delineator
  14. 10. Working with Text Fields
    1. Working with Text Fields
      1. The TextField class
      2. Dynamic text fields
        1. To create a dynamic text field at authortime and set its text properties at runtime
        2. To create a dynamic text field and set its text properties at runtime
      3. Input text fields
        1. To create an input text field at authortime and set its text properties at runtime
        2. To create an input text field and set its text properties at runtime
      4. Text field events
        1. To work with text field events
    2. Formatting Text Fields
      1. To format a text field using a TextFormat object
      2. HTML text formatting
      3. To format a TextField with HTML
    3. Embedding Fonts
      1. To create a font symbol and apply it to a TextField object with ActionScript
  15. 11. Working with the Math and Date Classes
    1. The Math Class
      1. Obtaining random numbers
        1. To generate random numbers
      2. Rounding numbers
        1. To round numbers
    2. The Date Class
      1. Getting the date and time
        1. To get and display the date and time
      2. Building a simple clock application
        1. To build a simple clock application
      3. Setting a custom date and time
        1. To set a custom date and time
    3. Time Zones and UTC Time
  16. 12. Working with Data Using Arrays and Objects
    1. Working with the Array Class
      1. Creating an array
      2. Adding elements to an array
        1. To create and add elements to an array
        2. To retrieve elements from an array
      3. Array constructor shorthand
        1. To pass indexed elements in the Array constructor method
        2. To create an array with an array literal
    2. Manipulating Arrays
      1. Adding or removing elements to and from an array
      2. Adding elements to an array
        1. To add elements to an array
      3. Removing or returning elements from an array
        1. To remove elements from an array
      4. Iterating through arrays
        1. To loop through an array
    3. The Object Class and Associative Arrays
      1. The Object class
      2. Array Accessor
        1. To create a custom object and its properties
      3. Associative arrays
        1. To create an associative array
        2. To loop through an associative array
  17. 13. Creating Conditional Statements
    1. Conditional Statements
      1. Relational and equality operators
        1. To check for true conditions using relational and equality operators
        2. To check for false conditions using relational and equality operators
      2. Verifying the value of a Boolean with a conditional statement
        1. To verify properties of a MovieClip using a conditional statement
      3. Verifying for multiple conditions
      4. Object-based relational operators
        1. To verify an object type
      5. Checking for multiple event types in a single event handler
        1. To check for multiple MouseEvent types in a single event handler
    2. Checking for Conditions Using the Switch Statement
      1. To check for conditions using the switch statement
  18. 14. Iteration and Repetition
    1. The for Loop Statement
      1. To create a for loop
      2. Iterating through array elements using the for loop
        1. To iterate through an indexed array using the for loop
      3. The “loop of death”
    2. Building a Dynamic Menu Using an Associative Array
      1. To build a reusable menu button class
      2. To build a dynamic menu
    3. Iterating Object Properties
      1. Retrieving properties of an object using the for..in loop
        1. To iterate through array elements using the for..in loop
        2. To iterate through object properties using the for..in loop
      2. Retrieving properties of an object using the for each..in loop
        1. To iterate through array elements using the for each..in loop
        2. To iterate through object properties using the for each..in loop
    4. The while and do...while Loop Statements
      1. To use the while loop
      2. To use the do...while loop
  19. 15. HTTP Requests and External Communications
    1. URL Navigation with HTTP Requests
      1. Making an HTTP request
      2. Navigating to a URL
        1. To browse to URLs using the navigateToURL() function
    2. Loading External Text Content
      1. To load and track the loading progress of a URLLoader object
      2. Loading external text and formatting with HTML
        1. To load external text into a text field
      3. Loading an external CSS file
        1. To style a text field with CSS
    3. Error Handling
      1. To create an error panel
  20. 16. Loading External Assets
    1. Using the Loader Class to Load External Data
      1. To load an external graphic with a Loader object
      2. Loading an external SWF file
        1. To load an external SWF with a Loader object
      3. The LoaderInfo object
    2. Monitoring Load Progress
      1. To display the percentage of a load
    3. Controlling Externally Loaded SWFs
      1. To load a SWF and cast it as a MovieClip
      2. To set properties of a loaded SWF
      3. To call methods of a loaded SWF
  21. 17. Using Shapes, Masks, Blends, and Filters
    1. The Shape Class
      1. To draw a rectangle using the Shape class
      2. To draw a rounded rectangle using the Shape class
      3. To draw a circle using the Shape class
    2. Applying Dynamic Masking to Objects
      1. To create a dynamic mask using a MovieClip created at authortime
      2. To create a dynamic mask using the Shape class
      3. To create a mask that rounds the corner of an image
    3. Creating Visual Effects with ActionScript
      1. Blend modes
        1. To apply a blend mode
      2. Dynamic filters
        1. To apply a blur filter to a display object
        2. To apply a drop shadow filter to a display object
  22. 18. Dynamic Animation
    1. The Timer Class
      1. To listen for events of the Timer class
      2. To animate a display object with the Timer class
      3. To loop the circle animation in the viewable area of the stage
    2. The ENTER_FRAME Event
      1. To animate using the ENTER_FRAME event
    3. The Tween and Easing Classes
      1. To tween a display object using the Tween class
      2. To tween multiple properties using the Tween class
      3. The Easing class
        1. To tween a display object with an easing method
      4. Controlling tween playback
        1. To control a Tween object’s playback
      5. TweenEvents
        1. To listen for events from a Tween object
    4. Transitions
      1. To use the TransitionManager with transitions
    5. Caching Display Objects
      1. To enable bitmap caching
  23. 19. Working with Sound
    1. Working with Embedded Sound
      1. To instantiate and play an embedded sound
    2. Controlling Playback with SoundChannel
      1. To stop the playback of a sound
    3. Loading External Sounds
      1. To load and play an external sound
    4. Monitoring Loading with Sound Events
      1. To track the loading progress of a sound file
    5. Using ID3 Data in MP3 Files
      1. To get ID3 data from an MP3 file
    6. Controlling a Sound’s Volume
      1. To control the volume of a Sound object
    7. Monitoring Playback Progress
      1. To display the playback progress of a sound in a text field
  24. 20. Working with Video
    1. Using the FLVPlayback Component
      1. Setting properties of an FLVPlayback component
        1. To set the properties of an FLVPlayback component
      2. Customizing the FLVPlayback component
        1. To attach custom UI controls to the FLVPlayback component
    2. FLVPlayback Events
      1. To monitor the playback of an FLVPlayback component
      2. Displaying video status
        1. To display the status of video playback in a text field
      3. FLV metadata
        1. To get FLV metadata information
      4. Adding and listening for cuepoints
      5. ActionScript cuepoints
        1. To add and listen for cuepoints with ActionScript
    3. Advanced Video Applications