Learning ActionScript 3.0

Book description

In this book, authors Rich Shupe and Zevan Rosser share the knowledge they've gained from their years as multimedia developers/designers and teachers. Learning ActionScript 3.0 gives you a solid foundation in the language of Flash and demonstrates how you can use it for practical, everyday projects.

The authors do more than just give you a collection of sample scripts. Written for those of you new to ActionScript 3.0, the book describes how ActionScript and Flash work, giving you a clear look into essential topics such as logic, event handling, displaying content, migrating legacy projects to ActionScript 3.0, classes, and much more. You will learn important techniques through hands-on exercises, and then build on those skills as chapters progress.

ActionScript 3.0 represents a significant change for many Flash users, and a steeper learning curve for the uninitiated. This book will help guide you through a variety of scripting scenarios. Rather than relying heavily on prior knowledge of object-oriented programming (OOP), topics are explained in focused examples that originate in the timeline, with optional companion classes for those already comfortable with their use. As chapters progress, the book introduces more and more OOP techniques, allowing you to choose which scripting approach you prefer.

Learning ActionScript 3.0 reveals:

  • New ways to harness the power and performance of AS3
  • Common mistakes that people make with the language
  • Essential coverage of text, sound, video, XML, drawing with code, and more
  • Migration issues from AS1 and AS2 to AS3
  • Simultaneous development of procedural and object-oriented techniques
  • Tips that go beyond simple script collections, including how to approach a project and which resources can help you along the way
The companion web site contains material for all the exercises in the book, as well as short quizzes to make sure you're up to speed with key concepts. ActionScript 3.0 is a different animal from previous versions, and Learning ActionScript 3.0 teaches everything that web designers, GUI-based Flash developers, and those new to ActionScript need to start using the language.

Publisher resources

View/Submit Errata

Table of contents

  1. A Note Regarding Supplemental Files
  2.  
  3. PREFACE
    1. Who This Book Is For
    2. How This Book Is Organized
    3. What Is—and Isn’t—In This Book
      1. What’s In
      2. What’s Not
    4. Companion Web Site
    5. Typographical Conventions Used In This Book
    6. Using Code Examples
    7. We’d Like to Hear from You
    8. Acknowledgments
  4. Index
  5. About the Authors
  6. Colophon
  7. I. GETTING STARTED
    1. 1. ACTIONSCRIPT OVERVIEW
      1. What Is ActionScript 3.0?
      2. The Flash Platform
      3. Procedural Versus Object-Oriented Programming
      4. The Document Class
      5. Legacy Code Compatibility
      6. What’s Next?
    2. 2. CORE LANGUAGE FUNDAMENTALS
      1. Miscellaneous Basics
      2. Variables and Data Types
      3. Conditionals
        1. if
        2. switch
      4. Loops
        1. for Loop
        2. while Loop
        3. A Loop Caveat
      5. Arrays
      6. Functions
      7. Custom Objects
      8. this
      9. Absolute versus Relative Addresses
      10. What’s Next?
  8. II. GRAPHICS AND INTERACTION
    1. 3. PROPERTIES, METHODS, AND EVENTS
      1. Inherited Attributes
      2. Properties
      3. Events
        1. Using Event Listeners
        2. Using Mouse Events to Control Properties
      4. Methods
        1. Using Keyboard Events to Call Methods
      5. Event Propagation
      6. Frame and Timer Events
        1. Frame Events
        2. Timer Events
      7. Removing Event Listeners
      8. What’s Next?
    2. 4. THE DISPLAY LIST
      1. The Sum of Its Parts
        1. Display List Classes
        2. Displaying the Display List
          1. The showChildren() function in action
      2. Adding and Removing Children
        1. Using addChild()
        2. Adding Symbol Instances to the Display List
        3. Using addChildAt()
        4. Removing Objects from the Display List and from Memory
          1. Preventing out of bounds errors
          2. Removing objects from memory
      3. Managing Object Names, Positions, and Data Types
        1. Finding Children by Position and by Name
        2. Casting a Display Object
      4. Changing the Display List Hierarchy
        1. Depth Management
        2. Reparenting Children
      5. A Dynamic Navigation Bar
      6. What’s Next?
    3. 5. TIMELINE CONTROL
      1. Playhead Movement
      2. Frame Labels
        1. New Timeline ActionScript
      3. Frame Rate
      4. A Simple Site or Application Structure
      5. What’s Next?
    4. 6. OOP
      1. Classes
        1. Custom Class Review
        2. Classpaths
      2. Inheritance
        1. Symbol Base Classes
        2. A More Traditional Look at Inheritance
          1. Vehicle class
          2. Main Flash file
          3. Car class
          4. Truck class
          5. Revised main Flash file
      3. Composition
        1.  
          1. Vehicle class
          2. Car class
          3. Truck class
          4. New Tires class
          5. Main Flash file
      4. Encapsulation
        1.  
          1. Vehicle class
          2. Car class
          3. Truck class
          4. Tires class and main Flash file
      5. Polymorphism
        1.  
          1. Vehicle class
          2. Car class
          3. Truck class
          4. Tires class and main Flash file
      6. Navigation Bar Revisited
        1.  
          1. Document class
          2. NavigationBar
          3. MenuButtonMain
      7. What’s Next?
    5. 7. MOTION
      1. Basic Movement
        1. Velocity
        2. Acceleration
      2. Geometry and Trigonometry
        1. Distance
        2. Movement Along an Angle
        3. Circular Movement
        4. Rotation Toward an Object
      3. Physics
        1. Gravity
        2. Friction
          1. Zeno’s Paradox
        3. Elasticity
      4. Programmatic Tweening
      5. Timeline Animation Recreations
      6. Particle Systems
      7. What’s Next?
    6. 8. DRAWING WITH VECTORS
      1. The Graphics Class
        1. Drawing Lines
        2. Drawing Curves
        3. Adding Solid Fills
        4. Drawing Shapes
        5. Using Gradient Fills
        6. Simulating the Pencil Tool
      2. The Geometry Package
        1. Creating Points
        2. Creating Rectangles
        3. Using Matrices
          1. Skewing with matrices
          2. Calculating changes in points after transformations
          3. Creating better gradient fills
      3. The Motion Package
      4. 9-Slice Scaling
      5. Applied Examples
        1. A Simple Color Picker
        2. A Custom Button Class
      6. What’s Next?
    7. 9. DRAWING WITH PIXELS
      1. Bitmap Caching
      2. The BitmapData Class
        1. Creating Bitmaps
        2. Using a Bitmap from the Library
        3. Copying Pixels
        4. Getting and Setting Pixels
          1. Get Pixel
          2. Set Pixel
        5. Drawing into a Bitmap
      3. Blend Modes
      4. Bitmap Filters
        1. Basic Filters
        2. Advanced Filters
          1. ConvolutionFilter
          2. Other Flash effects
          3. Perlin noise
            1. DisplacementMap
      5. Color Effects
        1. ColorTransform
        2. ColorMatrixFilter
        3. Color
      6. Image Encoding and Saving
        1. ActionScript
        2. PHP
      7. What’s Next?
  9. III. TEXT
    1. 10. TEXT
      1. Creating Text Fields
      2. Setting Text Field Characteristics
        1. Dynamic Text Fields
        2. Input Text Fields
      3. Selecting Text
      4. Formatting Text
        1. Tab Stops
        2. Embedded Fonts and Custom Anti-Aliasing
      5. Formatting with HTML and CSS
        1. HTML
        2. CSS
      6. Triggering ActionScript from HTML Links
      7. Parsing Text Fields
        1. Retrieving Line Data
        2. Retrieving Character and Paragraph Data
      8. Loading HTML and CSS
      9. What’s Next?
  10. IV. SOUND AND VIDEO
    1. 11. SOUND
      1. ActionScript Sound Architecture
      2. Internal and External Sounds
        1. Working with Sounds in Your Library
        2. Loading External Sounds
      3. Playing, Stopping, and Pausing Sounds
        1. Playing Sounds
        2. Stopping Sounds
        3. Pausing Sounds and Resuming Playback
      4. Buffering Streaming Sounds
      5. Changing Sound Volume and Pan
      6. Reading ID3 Metadata from MP3 Sounds
      7. Visualizing Sound Data
      8. Working with Microphone Sound
      9. Waveform Visualization
        1. The SoundPlayBasic Class
        2. The Visualization Class
        3. The Impact of Select Parameters
      10. What’s Next?
    2. 12. VIDEO
      1. Encoding
      2. Components
        1. Working with the FLVPlayback Component
      3. Full-Screen Video
      4. Captions
        1. Creating Captions with Timed Text
        2. Using the Timed Text File
        3. Creating Captions with Cue Points
        4. Using the FLV Cue Point Captions
        5. Providing Captions in Multiple Languages
          1. Timed Text
          2. Cue points
      5. Coding Your Own Video Playback
      6. What’s Next?
  11. V. INPUT/OUTPUT
    1. 13. LOADING ASSETS
      1. Loading Sound and Video
      2. Loading Text
        1. Loading Variables
        2. Using a Multiuse Text Loader
          1. LoadText.as
      3. Loading Display Objects
        1.  
          1. LoadDisplayObject.as
      4. Communicating Across ActionScript Virtual Machines
      5. Taking a Brief Look at Security
        1. Security Sandboxes
          1. Local versus network
          2. Same versus cross-domain
        2. Inter-Sandbox Access Solutions
          1. Administrator and user controls for local and network realms
          2. Web site controls (cross-domain policy files)
        3. Author (developer) controls
        4. Caveat emptor
      6. What’s Next?
    2. 14. XML and E4X
      1. Understanding XML Structure
        1. White Space
        2. Declarations
        3. Comments and Processing Instructions
        4. Entities and the CDATA Tag
      2. Creating an XML Object
      3. Reading XML
        1. Element Nodes
        2. Using Text Nodes
        3. Using Attributes
        4. Finding Elements by Content
        5. Finding Elements by Relationship
      4. Writing XML
      5. Deleting XML Elements
      6. Loading External XML Documents
      7. Communicating with XML Servers
        1. Send and Load
          1. savexml.php
        2. Sockets
      8. An XML-Based Navigation System
        1.  
          1. Document class:
          2. NavigationBar
          3. FadeRollOver
          4. MenuButtonMain
          5. MenuButtonSub
          6. LoadXML
          7. XML data file
      9. What’s Next?
  12. VI. PROGRAMMING DESIGN AND RESOURCES
    1. 15. PROGRAMMING DESIGN AND RESOURCES
      1. Programming Design Methodologies
        1. Waterfall
        2. Iterative
          1. Prototyping
        3. Agile
          1. Extreme Programming (XP)
        4. V-Model
        5. Spiral
        6. No Perfect Solution
      2. Object-Oriented Design Patterns
        1. Select Pattern Descriptions
          1. Creational patterns
          2. Structural patterns
          3. Behavioral patterns
        2. The Singleton Pattern
          1. An example singleton
          2. Singleton.as
          3. SingletonExample.as
          4. The pattern in action
      3. Resources
        1. Blogs
          1. Aggregators
          2. Blogs
        2. Forums
        3. Books
        4. Video Training
        5. Conferences
        6. Libraries
          1. Collections
          2. 3D
          3. Games
          4. Media
          5. Tweening
          6. Data/File Exchange
          7. Maps
          8. Social Networking
          9. Documentation
      4. What’s Next?
  13. Copyright

Product information

  • Title: Learning ActionScript 3.0
  • Author(s): Rich Shupe, Zevan Rosser
  • Release date: December 2007
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596527877