You are previewing Macromedia® Flash® 8 ActionScript: Training from the Source.
O'Reilly logo
Macromedia® Flash® 8 ActionScript: Training from the Source

Book Description

As any Flash developer worth his or her salt knows, you’re not tapping all of the program’s power unless you’re taking advantage of its scripting language. Not to worry: With Flash 8’s improved scripting language (which includes a visual interface!) and this project-based guide you don’t have to be a master programmer to do so. In these pages authors Jobe Makar and Danny Patterson, use hands-on lessons and simple, step-by-step instructions to translate real-life activities into scripts, in the process demonstrating that scripting is something you already instinctively know how to do. To that end, the authors have provided methodologies and techniques for building nearly 40 real-life Flash 8 ActionScript projects, including sample games, wireless applications, Web sites, and more—all of which will help you work faster and more efficiently. The companion CD contains all of the project files and images you’ll need to complete the book’s lessons.

Table of Contents

  1. Copyright
    1. Dedications
  2. Credits
  3. Bios
  4. Acknowledgments
  5. Introduction
    1. Outline
    2. Standard Elements in the Book
    3. Macromedia Training from the Source
    4. Macromedia Authorized Training and Certification
    5. What You Will Learn in This Book
    6. Minimum System Requirements
      1. Windows
      2. Macintosh
  6. 1. Introduction to ActionScript 2.0
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. What Is ActionScript?
      1. Events
      2. Actions
      3. Operators
      4. Keywords
      5. Data
      6. Curly Braces
      7. Semicolons
      8. Dot Syntax
      9. Parentheses
      10. Quotation Marks
      11. Comments
      12. Indenting/Spacing
    5. Using the Actions Panel
      1. Launching the Actions Panel
      2. Script Pane
      3. Toolbar
        1. Add a New Item to the Script
        2. Find
        3. Check Syntax
        4. Auto Format
        5. Insert a Target Path
        6. Show Code Hint
        7. Debug Options
        8. Script Assist
        9. Reference
        10. Menu
        11. Import Script
        12. Export Script
        13. Line Numbers
        14. Word Wrap
        15. Preferences
      4. Actions Toolbox
      5. Script Navigator
      6. Script Assist
    6. Creating Variables
      1. The Syntax
      2. Data Types and Strict Data Typing
    7. Code Placement
      1. Frames
      2. Buttons
      3. Movie Clips
      4. Best Practices
        1. Best Practice 1
        2. Best Practice 2
    8. Understanding Objects, Classes, and Scope
      1. Objects and Classes
      2. Scope
    9. What You Have Learned
  7. 2. Functions
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. Creating Functions
      1. Syntax 1
      2. Syntax 2
    5. Adding Parameters to Functions
    6. Using Local Variables and Creating Functions that Return Results
      1. Returning Results from a Function Call
    7. What You Have Learned
  8. 3. Conditional Logic
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. Controlling a Script’s Flow
      1. if/else Statements
      2. if/else if Statements
      3. if/else Statements
      4. switch/case Statements
      5. Conditional Operator
    5. Reacting to Multiple Conditions
    6. Reacting to User Interaction
    7. Detecting the Edge of the Stage
    8. What You Have Learned
  9. 4. Arrays and Loops
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. Why Loops Are Useful
    5. Types of Loops
      1. while Loop
      2. for Loop
      3. for...in Loop
    6. Loop Exceptions
    7. Creating a Search Application
    8. Writing and Understanding Loop Conditions
    9. Nested Loops
    10. What You Have Learned
  10. 5. Built-in Classes
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. What Classes Are and Why They’re Useful
      1. Understanding the Concept of Classes and Instances
      2. Properties
      3. Methods
      4. Built-in Classes
      5. Accessibility Class (Top-Level)
      6. Array Class (Instances)
      7. Boolean Class (Instances)
      8. Button Class (Instances)
      9. Capabilities Class (Top-Level)
      10. Color Class (Instances)
      11. ContextMenu Class (Instances)
      12. ContextMenuItems Class (Instances)
      13. Date Class (Instances)
      14. Error Class (Instances)
      15. Key Class (Top-Level)
      16. LoadVars Class (Instances)
      17. Math Class (Top-Level)
      18. Mouse Class (Top-Level)
      19. MovieClip Class (Instances)
      20. MovieClipLoader Class (Instances)
      21. NetConnection Class (Instances)
      22. NetStream Class (Instances)
      23. Number Class (Top-Level)
      24. Object Class (Instances)
      25. PrintJob Class (Instances)
      26. Selection Class (Top-Level)
      27. Sound Class (Instances)
      28. Stage Class (Top-Level)
      29. String Class (Instances)
      30. StyleSheet Class (Instances)
      31. System Class (Top-Level)
      32. TextField Class (Instances)
      33. TextFormat Class (Instances)
      34. XML Class (Instances)
      35. XMLSocket Class (Instances)
    5. Using the Color Class
    6. Working with String and Selection Classes
    7. What You Have Learned
  11. 6. Custom Classes
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. Understanding Classes, Top-Level Classes, and Instances
    5. Creating a Class
    6. Understanding the Classpath
      1. Global Classpath
      2. Document-Level Classpath
    7. Using Packages and Importing Classes
    8. Using Getters and Setters
      1. Using Implicit get and set Methods
    9. Defining Members
      1. Public and Private Members
      2. Static Members
    10. Understanding Inheritance
    11. Updating an Inheritance-Based Project
    12. What You Have Learned
  12. 7. Events, Listeners, and Callbacks
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. What Events Do
    5. Types of Events in Flash
    6. Event Handlers
    7. Creating a Project Using Event Handlers
    8. Listeners
    9. Creating a Project Using Listeners
    10. What You Have Learned
  13. 8. Dynamically Creating Assets
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. Attaching Movie Clips
    5. Adding Empty Movie Clips
    6. Drawing Programmatically
    7. Working with Movie Clips as Buttons
    8. Adding Text Fields Programmatically
    9. Formatting Text
    10. What You Have Learned
  14. 9. Bitmap Features
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. Using Bitmap Surface Caching
    5. Applying Filters
      1. Constructing Filters
      2. Assigning Filters to Objects
      3. Building a Spaceship Game
      4. Retrieving Filters
      5. Appending Filters
      6. Deleting Filters
      7. Updating Filters
      8. Continuing the Spaceship Game
      9. Completing the Spaceship Game
    6. Applying Blend Modes Programmatically
    7. Introducing the Bitmap API
      1. Constructing BitmapData Objects
      2. Displaying BitmapData Content
      3. Building a Coloring Page Program
      4. Applying Flood Fills
      5. Working with Pixels
      6. Continuing the Coloring Page Program
      7. Copying Content
      8. Completing the Coloring Page Program
    8. What You Have Learned
  15. 10. UI Components
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. Components: A Scripting Primer
    5. Configuring Component Properties
      1. Common Properties
      2. Component-Specific Properties
    6. Triggering Scripts Using Component Events
      1. Common Events
      2. Component-Specific Events
      3. Handling Events
    7. Using Component Methods
      1. Common Methods
      2. Component-Specific Methods
    8. Using the FocusManager Component
      1. Scenario 1
      2. Scenario 2
    9. Customizing UI Components with ActionScript
    10. What You Have Learned
  16. 11. Advanced Object-Oriented Design
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. Correcting Scope Errors with Delegate
    5. Understanding Encapsulation
    6. Applying Composition
    7. Using Composition and Inheritance Together
    8. Dispatching Events
    9. What You Have Learned
  17. 12. Data Validation
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. The Logic Behind Validating Data
    5. Using Validation Routines
    6. Handling Errors
    7. Validating Strings
    8. Validating Sequences
    9. Validating Against a List of Choices
    10. Validating Numbers
    11. Processing Validated Data
    12. What You Have Learned
  18. 13. External Data Connections
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. Understanding Data Sources and Data Formats
    5. GET versus POST
    6. Using the LoadVars Class
    7. Policy Files
    8. Using Shared Objects
    9. Using the WebServiceConnector Component
    10. What You Have Learned
  19. 14. XML and Flash
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. XML Basics
    5. Using the XML Class
      1. Formatting XML
      2. Parsing XML
      3. Loading XML
      4. Sending XML
    6. Using Socket Servers
      1. Introduction to the XMLSocket Class
      2. ElectroServer 3
      3. ElectroServer Class
    7. What You Have Learned
  20. 15. External Interface
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. Getting Started with ExternalInterface
    5. Configuring HTML for Basic ExternalInterface Calls
    6. Calling JavaScript Functions from ActionScript
    7. Using JavaScript Functionality from Flash
    8. Calling ActionScript Functions from JavaScript
      1. Registering an ActionScript Function
      2. Getting a Flash Object Reference
    9. Building a Quiz Application
    10. What You Have Learned
  21. 16. Sound and Video
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. Controlling Sound with ActionScript
    5. Creating a Sound Instance
    6. Dragging a Movie Clip Instance Within a Boundary
    7. Controlling Volume
    8. Controlling Panning
    9. Attaching Sounds and Controlling Sound Playback
    10. Loading and Controlling External Video
    11. What You Have Learned
  22. 17. Printing and Context Menus
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. Flash Printing versus Browser Printing
    5. Using the PrintJob Class
    6. Creating Custom Context Menus
    7. What You Have Learned
  23. 18. Maximum-Strength SWF Files
    1. What You Will Learn
    2. Approximate Time
    3. Lesson Files
    4. Understanding fscommand()
      1. Controlling the Stand-Alone Flash Player (Projectors)
      2. Executing AppleScripts with fscommand() Functions
      3. Communicating with a Web Browser
      4. Creating an Enhanced Executable (Projector)
    5. Using Zinc
    6. Using FlashVars
    7. What You Have Learned