Foundation ActionScript 3.0 for Flash and Flex

Book description

This book covers all the essential ActionScript 3.0 techniques from the ground up, allowing you to get up and running quickly and easily.

Table of contents

  1. Copyright
  2. ABOUT THE AUTHORS
  3. ABOUT THE COVER IMAGE DESIGNER
  4. LAYOUT CONVENTIONS
  5. 1. GETTING STARTED WITH ACTIONSCRIPT 3.0
    1. 1.1. A brief history of ActionScript
    2. 1.2. The rise of ActionScript 3.0
    3. 1.3. ActionScript and object-oriented programming
    4. 1.4. The development process
    5. 1.5. Organizing your files
    6. 1.6. Adding ActionScript to your projects
      1. 1.6.1. Placing code on the timeline
      2. 1.6.2. Importing code from an external file
      3. 1.6.3. Specifying a document class
      4. 1.6.4. Linking library assets to external classes
    7. 1.7. Bouncing balls
      1. 1.7.1. Creating the Flash file
      2. 1.7.2. Creating the Ball class
      3. 1.7.3. Adding more balls
    8. 1.8. ActionScript in action
    9. 1.9. Summary
  6. 2. ACTIONSCRIPT 3.0 FUNDAMENTALS
    1. 2.1. Statements and expressions
    2. 2.2. Introducing variables
      1. 2.2.1. Assigning a value to a variable
      2. 2.2.2. Retrieving the value of a variable
      3. 2.2.3. Naming your variables
      4. 2.2.4. Understanding data types
        1. 2.2.4.1. Boolean data type
        2. 2.2.4.2. Numeric data types
    3. 2.3. Using constants
    4. 2.4. Performing operations
      1. 2.4.1. Arithmetic operators
      2. 2.4.2. Specifying precedence
      3. 2.4.3. String operations
      4. 2.4.4. Unary operations
    5. 2.5. Introducing arrays
      1. 2.5.1. Manipulating arrays
    6. 2.6. Making decisions
      1. 2.6.1. Introducing the if statement
      2. 2.6.2. Forming Boolean expressions
      3. 2.6.3. Booleans in conditionals
      4. 2.6.4. Using logical operators
    7. 2.7. Looping the loop
      1. 2.7.1. The while loop
      2. 2.7.2. The do . . . while loop
      3. 2.7.3. The for loop
      4. 2.7.4. Looping through an array
      5. 2.7.5. More for loops
      6. 2.7.6. Breaking out of a loop
    8. 2.8. Introducing functions
      1. 2.8.1. Creating a function
      2. 2.8.2. Returning a value from a function
      3. 2.8.3. Using function parameters
      4. 2.8.4. Providing a default value for function parameters
      5. 2.8.5. Allowing for variable parameters
      6. 2.8.6. Passing values and references
      7. 2.8.7. Function scope
    9. 2.9. Commenting your code
      1. 2.9.1. Bad vs. good comments
      2. 2.9.2. Commenting for documentation
    10. 2.10. Summary
  7. 3. OBJECTS AND CLASSES
    1. 3.1. iPod analogy
    2. 3.2. Working with objects
      1. 3.2.1. Creating objects using the new operator
      2. 3.2.2. Accessing properties and calling methods
      3. 3.2.3. Copying objects
      4. 3.2.4. Casting objects to a type
      5. 3.2.5. The Object object
      6. 3.2.6. Iterating over objects
        1. 3.2.6.1. For in loop
        2. 3.2.6.2. For each loop
    3. 3.3. Creating your first class
      1. 3.3.1. Choosing suitable names for your classes
    4. 3.4. Adding properties
    5. 3.5. Adding methods
      1. 3.5.1. Initializing your objects with a constructor method
    6. 3.6. Controlling access to properties and methods
    7. 3.7. Adding getter/setter methods
      1. 3.7.1. Creating read-only properties with getter methods
    8. 3.8. Static properties and methods
    9. 3.9. Taking advantage of inheritance
      1. 3.9.1. Overriding methods of the base class
    10. 3.10. Using packages to group your classes
      1. 3.10.1. Naming your packages
      2. 3.10.2. Importing a class from a package
      3. 3.10.3. Importing all classes in a given package
      4. 3.10.4. Resolving naming conflicts among imported classes
    11. 3.11. Removing dependency on timeline code
    12. 3.12. Summary
  8. 4. WORKING WITH THE DISPLAY
    1. 4.1. Introducing the display list
    2. 4.2. Working with display objects
      1. 4.2.1. Manipulating display objects
      2. 4.2.2. Managing depth
        1. 4.2.2.1. Discovering the depth of objects
        2. 4.2.2.2. Manipulating the depth of objects
        3. 4.2.2.3. Swapping depths
      3. 4.2.3. Creating new display objects
      4. 4.2.4. Removing display objects from the display list
    3. 4.3. Specifying blend modes
    4. 4.4. Working with filters
      1. 4.4.1. Applying a filter to a display object
      2. 4.4.2. Applying filters in a specific order
      3. 4.4.3. Making changes to an existing filter
      4. 4.4.4. Removing an existing filter
      5. 4.4.5. Introducing the advanced filters
    5. 4.5. Accessing the stage
      1. 4.5.1. Using Stage properties
      2. 4.5.2. Making a movie full screen
    6. 4.6. Using Library resources
    7. 4.7. Loading from external files
      1. 4.7.1. Loading an external asset
      2. 4.7.2. Manipulating the loaded asset
    8. 4.8. Making things move
      1. 4.8.1. Copying animation from the timeline
        1. 4.8.1.1. Creating the animation
        2. 4.8.1.2. Copying the animation code
      2. 4.8.2. Animating other properties
    9. 4.9. Summary
  9. 5. CREATING VECTOR GRAPHICS WITH THE DRAWING API
    1. 5.1. Why we need a drawing API
    2. 5.2. Understanding the drawing API
    3. 5.3. Setting up Mr. Smiley
    4. 5.4. Drawing lines
      1. 5.4.1. Creating straight lines
      2. 5.4.2. Controlling the line style
      3. 5.4.3. Drawing curved lines
    5. 5.5. Drawing and filling shapes
      1. 5.5.1. Drawing primitive shapes
      2. 5.5.2. Creating custom shapes
      3. 5.5.3. Filling shapes with a solid color
      4. 5.5.4. Filling shapes with color gradients
    6. 5.6. Simplifying the code
    7. 5.7. Creating gradient line styles
    8. 5.8. Flash 3D
    9. 5.9. Summary
  10. 6. USER INTERACTION AND MORE WITH EVENTS
    1. 6.1. Understanding events
      1. 6.1.1. Listening for an event
      2. 6.1.2. Removing an event listener
      3. 6.1.3. Naming your event listener methods
      4. 6.1.4. Creating a simple drawing application
        1. 6.1.4.1. Setting up the canvas
        2. 6.1.4.2. Adding event listeners
        3. 6.1.4.3. Refreshing the screen
      5. 6.1.5. Using one event listener for multiple objects
    2. 6.2. Using events with the display list
      1. 6.2.1. Handling single and double mouse clicks
      2. 6.2.2. Handling mouse hover states
        1. 6.2.2.1. Responding to a rollover event
        2. 6.2.2.2. Making colors constants
      3. 6.2.3. Handling key presses
        1. 6.2.3.1. Setting up a keyboard drawing application
        2. 6.2.3.2. Handling crosshair movement
      4. 6.2.4. Preventing an event's default action
    3. 6.3. Capturing and bubbling: the event flow
      1. 6.3.1. Listening for events in the bubble phase
      2. 6.3.2. Listening for events in the capture phase
      3. 6.3.3. Stopping an event from propagating
      4. 6.3.4. Removing capture phase event listeners
    4. 6.4. Summary
  11. 7. WORKING WITH VIDEO
    1. 7.1. Video on the modern Web
      1. 7.1.1. The video experience
      2. 7.1.2. Where ActionScript comes in
    2. 7.2. Encoding your video
      1. 7.2.1. Capturing your video
      2. 7.2.2. Using the Flash Video Encoder
    3. 7.3. Delivering your video
    4. 7.4. Using ActionScript to play videos
      1. 7.4.1. Managing connections with the NetConnection class
      2. 7.4.2. Loading and controlling video with the NetStream class
        1. 7.4.2.1. Buffering your video
        2. 7.4.2.2. Playing your video
        3. 7.4.2.3. Pausing your video
        4. 7.4.2.4. Stopping your video
        5. 7.4.2.5. Fast-forwarding and rewinding your video
      3. 7.4.3. Creating video objects with the Video class
      4. 7.4.4. Creating camera objects with the Camera class
      5. 7.4.5. Handling video events
        1. 7.4.5.1. Mouse events
        2. 7.4.5.2. Status events
        3. 7.4.5.3. Metadata events
        4. 7.4.5.4. Cue point events
    5. 7.5. Building a video player
      1. 7.5.1. Setting up the project
        1. 7.5.1.1. Creating the Main.as file
        2. 7.5.1.2. Creating the Videos.as file
      2. 7.5.2. Controlling the video player
        1. 7.5.2.1. Setting up the status text field
        2. 7.5.2.2. Implementing the loading progress bar
        3. 7.5.2.3. Creating the playhead bar
        4. 7.5.2.4. Handling the metadata
        5. 7.5.2.5. Handling cue points
      3. 7.5.3. Controlling the video on the stage
        1. 7.5.3.1. Adding button functionality
        2. 7.5.3.2. Finishing the Videos.as class
      4. 7.5.4. Creating a custom event
    6. 7.6. Summary
  12. 8. USING AUDIO
    1. 8.1. Importing and converting sound files
      1. 8.1.1. Using iTunes
        1. 8.1.1.1. Converting to MP3 format
        2. 8.1.1.2. Adding ID3 information
      2. 8.1.2. Using Soundbooth
    2. 8.2. Using ActionScript to play sound
      1. 8.2.1. Accessing sound files with the Sound class
      2. 8.2.2. Controlling sound channels with the SoundChannel class
      3. 8.2.3. Doing security checks with the SoundLoaderContext class
      4. 8.2.4. Controlling volume and panning with the SoundTransform class
      5. 8.2.5. Controlling sounds globally with the SoundMixer class
      6. 8.2.6. Getting ID3 data with the ID3Info class
      7. 8.2.7. Using a microphone with the Microphone class
      8. 8.2.8. Understanding the basics of a sound player application
        1. 8.2.8.1. Preloading a buffer
        2. 8.2.8.2. Pausing sound
        3. 8.2.8.3. Stopping sound
        4. 8.2.8.4. Fast-forwarding and rewinding sound
        5. 8.2.8.5. Controlling volume
        6. 8.2.8.6. Controlling panning
        7. 8.2.8.7. Displaying the sound spectrum
        8. 8.2.8.8. Handling ID3 Tags
    3. 8.3. Building a sound player
      1. 8.3.1. Setting up the project
        1. 8.3.1.1. Creating the Main.as file
        2. 8.3.1.2. Creating the Sounds.as file
        3. 8.3.1.3. Loading the sound file
        4. 8.3.1.4. Buffering sound
      2. 8.3.2. Adding display items
        1. 8.3.2.1. Creating the loading progress bar
        2. 8.3.2.2. Creating the playhead bar
        3. 8.3.2.3. Adding the sound spectrum
        4. 8.3.2.4. Displaying ID3 track metadata
      3. 8.3.3. Controlling the audio as it plays
        1. 8.3.3.1. Adding button functionality
        2. 8.3.3.2. Handling button events
      4. 8.3.4. Controlling the sound volume and panning
      5. 8.3.5. Creating the custom event class
    4. 8.4. Summary
  13. 9. WORKING WITH COMPONENTS
    1. 9.1. Just what are components?
      1. 9.1.1. Accessing your components
      2. 9.1.2. Adjusting component parameters
    2. 9.2. Benefits of working with components
    3. 9.3. Exploring the Flash component framework
      1. 9.3.1. UI components
      2. 9.3.2. Video components
      3. 9.3.3. Going behind the scenes
      4. 9.3.4. Finding the files
        1. 9.3.4.1. Components directory
        2. 9.3.4.2. Component Source directory
    4. 9.4. Scripting interaction
      1. 9.4.1. Adding the components
      2. 9.4.2. Adding the ActionScript
    5. 9.5. Styling and skinning
      1. 9.5.1. Styling components
        1. 9.5.1.1. Setting up for changing styles
        2. 9.5.1.2. Setting styles for all components
        3. 9.5.1.3. Setting a style for all instances of a component
        4. 9.5.1.4. Setting the style for a single instance of a component
      2. 9.5.2. Skinning using the timeline
      3. 9.5.3. Skinning using classes
        1. 9.5.3.1. Creating a skin for the button's up state
        2. 9.5.3.2. Creating skins for the button's other states
        3. 9.5.3.3. Associating the skins with the buttons
    6. 9.6. Creating components from scratch
      1. 9.6.1. Creating the widget
      2. 9.6.2. Writing the component code
        1. 9.6.2.1. Handling events
        2. 9.6.2.2. Rotating the dial
        3. 9.6.2.3. Getting and setting dial values
        4. 9.6.2.4. Adding metatags
      3. 9.6.3. Turning the symbol into a component
      4. 9.6.4. Testing the component
    7. 9.7. Using third-party components
    8. 9.8. Summary
  14. 10. REGULAR EXPRESSIONS
    1. 10.1. Why you need regular expressions
    2. 10.2. Introducing the RegExp class
    3. 10.3. Anatomy of a regular expression pattern
      1. 10.3.1. Introducing metacharacters
        1. 10.3.1.1. Using anchors to restrict the position of matches
        2. 10.3.1.2. Using start-of-string anchors
        3. 10.3.1.3. Using end-of-string anchors
        4. 10.3.1.4. Combining anchors
      2. 10.3.2. Providing alternatives with alternation
      3. 10.3.3. Using character classes and character ranges
      4. 10.3.4. Matching any character using the dot metacharacter
      5. 10.3.5. Matching a number of occurrences using quantifiers
        1. 10.3.5.1. Matching zero or one occurrence
        2. 10.3.5.2. Matching zero or more occurrences
        3. 10.3.5.3. Matching one or more occurrences
        4. 10.3.5.4. How to prevent greedy quantifiers
        5. 10.3.5.5. Being more specific with bounds
      6. 10.3.6. Grouping patterns
      7. 10.3.7. Accessing matched strings with backreferences
        1. 10.3.7.1. Using backreferences with the String.replace() method
        2. 10.3.7.2. Using backreferences after the pattern has been matched
    4. 10.4. Understanding the e-mail regular expression pattern
    5. 10.5. Changing regular expression behavior with modifiers
      1. 10.5.1. Using the case-insensitive modifier
      2. 10.5.2. Using the global modifier
      3. 10.5.3. Using the multiline modifier
      4. 10.5.4. Using the dotall modifier
      5. 10.5.5. Using the extended modifier
    6. 10.6. Using variables to build a regular expression
    7. 10.7. Useful regular expressions
    8. 10.8. Regular expression resources
    9. 10.9. Summary
  15. 11. USING XML
    1. 11.1. Understanding XML and E4X
      1. 11.1.1. XML document components
        1. 11.1.1.1. Root node
        2. 11.1.1.2. Elements
        3. 11.1.1.3. Text nodes
      2. 11.1.2. E4X
        1. 11.1.2.1. Attributes
    2. 11.2. Accessing an XML file
      1. 11.2.1. Creating an XML object
      2. 11.2.2. Loading an XML file
      3. 11.2.3. Getting XML from a remote source
    3. 11.3. Reading the XML
      1. 11.3.1. Reading the root node
      2. 11.3.2. Reading elements in an XML tree
      3. 11.3.3. Reading an XML element's attributes
    4. 11.4. Searching XML
      1. 11.4.1. Searching for an attribute or element at any level
      2. 11.4.2. Reading text nodes
    5. 11.5. Modifying XML
      1. 11.5.1. Adding elements to an XML object
      2. 11.5.2. Removing elements and attributes from an XML object
    6. 11.6. Summary
  16. 12. CASE STUDY: CREATING A DYNAMIC IMAGE VIEWER
    1. 12.1. An overview of the image viewer
    2. 12.2. Laying out the interface
    3. 12.3. Creating the document class
    4. 12.4. Loading image data
      1. 12.4.1. Loading the XML
      2. 12.4.2. Parsing the data
      3. 12.4.3. Accessing the data
    5. 12.5. Displaying images
      1. 12.5.1. Handling image selection
      2. 12.5.2. Scaling an image
    6. 12.6. Adding graphic enhancements
      1. 12.6.1. Changing the image label
      2. 12.6.2. Improving the thumbnail layout
      3. 12.6.3. Adding drop shadows
      4. 12.6.4. Creating an animated transition
    7. 12.7. Summary
  17. 13. GETTING STARTED WITH FLEX
    1. 13.1. Introducing Flex
    2. 13.2. Understanding rich Internet applications
    3. 13.3. Meet the (Flex) family
      1. 13.3.1. The Flex framework
      2. 13.3.2. The Flash Player
      3. 13.3.3. MXML
      4. 13.3.4. The Flex Software Development Kit
      5. 13.3.5. Flex Builder
      6. 13.3.6. Adobe LiveCycle DS
      7. 13.3.7. Adobe AIR
    4. 13.4. Getting started with the Flex SDK
      1. 13.4.1. Installing the Flex SDK
        1. 13.4.1.1. Windows XP/Vista
        2. 13.4.1.2. Mac OS X
        3. 13.4.1.3. Linux
      2. 13.4.2. Finding a suitable editor
      3. 13.4.3. Building your first Flex application
    5. 13.5. Getting started with Flex Builder
      1. 13.5.1. Understanding the Flex Builder interface
      2. 13.5.2. Building your first Flex Builder application
        1. 13.5.2.1. Creating a new Flex project
        2. 13.5.2.2. Working in Design view
        3. 13.5.2.3. Working in Source view
    6. 13.6. Summary
  18. 14. FLEX BY EXAMPLE
    1. 14.1. Planning the application
      1. 14.1.1. Gathering the requirements
      2. 14.1.2. Creating the functional specification
      3. 14.1.3. Designing the UI
      4. 14.1.4. Designing the interaction
      5. 14.1.5. Designing the data and logic
    2. 14.2. Setting up the project
    3. 14.3. Creating the basic UI
      1. 14.3.1. Creating the containers
    4. 14.4. Creating basic feed integration
      1. 14.4.1. Installing the XML syndication library
    5. 14.5. Creating the Subscription class
      1. 14.5.1. Adding a new class to your project
      2. 14.5.2. Fleshing out the Subscription class
      3. 14.5.3. Testing the Subscription class
      4. 14.5.4. Loading the data
      5. 14.5.5. Allowing Subscription instances to be used for data binding
      6. 14.5.6. Creating the subscriptions list
      7. 14.5.7. Creating the articles data grid
      8. 14.5.8. Populating the Article panel
    6. 14.6. Completing the Subscriptions panel
      1. 14.6.1. Allowing users to subscribe to a feed
        1. 14.6.1.1. Laying out the SubscribeDialog component
        2. 14.6.1.2. Wiring up the buttons
        3. 14.6.1.3. Getting the feed
      2. 14.6.2. Allowing users to unsubscribe from a feed
      3. 14.6.3. Saving the subscriptions list between sessions
      4. 14.6.4. Refreshing the subscriptions list
        1. 14.6.4.1. Automatically refreshing the subscriptions list
        2. 14.6.4.2. Manually refreshing the subscriptions list
    7. 14.7. Completing the Articles and Article panels
      1. 14.7.1. Finishing the Articles panel
      2. 14.7.2. Finishing the Article panel
    8. 14.8. Improving the feed reader
    9. 14.9. Summary

Product information

  • Title: Foundation ActionScript 3.0 for Flash and Flex
  • Author(s):
  • Release date: August 2009
  • Publisher(s): Apress
  • ISBN: 9781430219187