You are previewing Foundation ActionScript 3.0 Animation: Making Things Move!.
O'Reilly logo
Foundation ActionScript 3.0 Animation: Making Things Move!

Book Description

Flash has long been one of the most approachable, user-friendly tools for creating web-based animations, games, and applications. This has contributed to making it one of the most widely used programs for creating interactive web content. With each new version of Flash, ActionScript, its built-in scripting language, has become more powerful and a little more complex, too. ActionScript, now at version 3.0, has significantly matured as a programming language, bringing power and speed only previously dreamed about to Flash-based animation, going far beyond traditionally used keyframes and tweens.

Table of Contents

  1. FOREWORD
  2. ABOUT THE AUTHOR
  3. ABOUT THE TECHNICAL REVIEWER
  4. ABOUT THE COVER IMAGE DESIGNER
  5. ACKNOWLEDGMENTS
  6. INTRODUCTION
    1. Layout conventions
  7. I. ACTIONSCRIPTED ANIMATION BASICS
    1. 1. BASIC ANIMATION CONCEPTS
      1. What is animation?
      2. Frames and motion
        1. Frames as records
        2. Programmed frames
      3. Dynamic vs. static animation
      4. Summary
    2. 2. BASICS OF ACTIONSCRIPT 3.0 FOR ANIMATION
      1. Basic animation
      2. A note on ActionScript versions
      3. Classes and OOP
        1. A basic class
        2. Packages
        3. Imports
        4. Constructors
        5. Inheritance
        6. A MovieClip/Sprite subclass
        7. Creating your document class
      4. Setting up an ActionScript 3.0 application
        1. Using the Flash CS3 IDE
        2. Using Flex Builder 2
        3. Using the free command-line compiler
        4. A note on tracing
        5. Scaling the movie
      5. Animating with code
        1. Looping
        2. Frame loops
        3. Clip events
        4. Events and event handlers
        5. Listeners and handlers
        6. Events for animation
      6. The display list
        1. Subclassing display objects
      7. User interaction
        1. Mouse events
        2. Mouse position
        3. Keyboard events
        4. Key codes
      8. Summary
    3. 3. TRIGONOMETRY FOR ANIMATION
      1. What is trigonometry?
      2. Angles
        1. Radians and degrees
        2. Flash's coordinate system
        3. Triangle sides
      3. Trig functions
        1. Sine
        2. Cosine
        3. Tangent
        4. Arcsine and arccosine
        5. Arctangent
      4. Rotation
      5. Waves
        1. Smooth up and down motion
        2. Linear vertical motion
        3. Pulsing motion
        4. Waves with two angles
        5. Waves with the drawing API
      6. Circles and ellipses
        1. Circular movement
        2. Elliptical movement
      7. Pythagorean Theorem
      8. Distance between two points
      9. Important formulas in this chapter
          1. Calculate basic trigonometric functions:
          2. Convert radians to degrees and degrees to radians:
          3. Rotate to the mouse (or any point):
          4. Create waves:
          5. Create circles:
          6. Create ovals:
          7. Get the distance between two points:
      10. Summary
    4. 4. RENDERING TECHNIQUES
      1. Colors in Flash
        1. Using hexadecimal color values
        2. Transparency and 32-bit color
        3. New number types: int and uint
        4. Combining colors
        5. Extracting component colors
      2. The Drawing API
        1. The graphics object
        2. Removing drawing with clear
        3. Setting line appearance with lineStyle
        4. Drawing lines with lineTo and moveTo
        5. Drawing curves with curveTo
          1. Curving through the control point
          2. Creating multiple curves
        6. Creating shapes with beginFill and endFill
        7. Creating gradient fills with beginGradientFill
          1. Specifying the fill type
          2. Setting the colors, alphas, and ratios
          3. Creating the matrix
      3. Color transforms
        1. Changing colors with the ColorTransform class
      4. Filters
        1. Creating a filter
        2. Animating filters
      5. Bitmaps
      6. Loading and embedding assets
        1. Loading assets
        2. Embedding assets
      7. Important formulas in this chapter
          1. Convert hex to decimal:
          2. Convert decimal to hex:
          3. Combine component colors:
          4. Extract component colors:
          5. Draw a curve through a point:
      8. Summary
  8. II. BASIC MOTION
    1. 5. VELOCITY AND ACCELERATION
      1. Velocity
        1. Vectors and velocity
        2. Velocity on one axis
        3. Velocity on two axes
        4. Angular velocity
          1. Vector addition
          2. A mouse follower
        5. Velocity extended
      2. Acceleration
        1. Acceleration on one axis
        2. Acceleration on two axes
        3. Gravity as acceleration
        4. Angular acceleration
        5. A spaceship
          1. Ship controls
      3. Important formulas in this chapter
          1. Convert angular velocity to x, y velocity:
          2. Convert angular acceleration (any force acting on an object) to x, y acceleration:
          3. Add acceleration to velocity:
          4. Add velocity to position:
      4. Summary
    2. 6. BOUNDARIES AND FRICTION
      1. Environmental boundaries
        1. Setting boundaries
        2. Removing objects
        3. Regenerating objects
        4. Screen wrapping
        5. Bouncing
      2. Friction
        1. Friction, the right way
        2. Friction, the easy way
        3. Friction applied
      3. Important formulas in this chapter
          1. Remove an out-of-bounds object:
          2. Regenerate an out-of-bounds object:
          3. Screen wrapping for an out-of-bounds object:
          4. Apply friction (the correct way):
          5. Apply friction (the easy way):
      4. Summary
    3. 7. USER INTERACTION: MOVING OBJECTS AROUND
      1. Pressing and releasing a sprite
      2. Dragging a sprite
        1. Dragging with mouseMove
        2. Dragging with startDrag/stopDrag
        3. Combining dragging with motion code
      3. Throwing
      4. Summary
  9. III. ADVANCED MOTION
    1. 8. EASING AND SPRINGING
      1. Proportional Motion
      2. Easing
        1. Simple easing
        2. When to stop easing
        3. A moving target
        4. Easing isn't just for motion
          1. Transparency
          2. Rotation
          3. Colors
        5. Advanced easing
      3. Springing
        1. Springing in one dimension
        2. Springing in two dimensions
        3. Springing to a moving target
        4. So where's the spring?
        5. Chaining springs
        6. Springing to multiple targets
        7. Offsetting the target
        8. Attaching multiple objects with springs
      4. Important formulas in this chapter
          1. Simple easing, long form:
          2. Simple easing, abbreviated form:
          3. Simple easing, short form:
          4. Simple spring, long form:
          5. Simple spring, abbreviated form:
          6. Simple spring, short form:
          7. Offset spring:
      5. Summary
    2. 9. COLLISION DETECTION
      1. Collision detection methods
      2. hitTestObject and hitTestPoint
        1. Hit testing two sprites
        2. Hit testing a sprite and a point
        3. Hit testing with shapeFlag
        4. Summary of hitTest
      3. Distance-based collision detection
        1. Simple distance-based collision detection
        2. Collision-based springing
      4. Multiple-object collision detection strategies
        1. Basic multiple-object collision detection
        2. Multiple-object springing
      5. Other methods of collision detection
      6. Important formulas in this chapter
          1. Distance-based collision detection:
          2. Multiple-object collision detection:
      7. Summary
    3. 10. COORDINATE ROTATION AND BOUNCING OFF ANGLES
      1. Simple coordinate rotation
      2. Advanced coordinate rotation
        1. Rotating a single object
        2. Rotating multiple objects
      3. Bouncing off an angle
        1. Performing the rotation
        2. Optimizing the code
        3. Making it dynamic
        4. Fixing the "falling off the edge" problem
          1. Hit testing
          2. Bounds checking
        5. Fixing the "under the line" problem
        6. Bouncing off multiple angles
      4. Important formulas in this chapter
          1. Coordinate rotation:
          2. Reverse coordinate rotation:
      5. Summary
    4. 11. BILLIARD BALL PHYSICS
      1. Mass
      2. Momentum
      3. Conservation of momentum
        1. Conservation of momentum on one axis
          1. Placing the objects
          2. Optimizing the code
        2. Conservation of momentum on two axes
          1. Understanding the theory and strategy
          2. Writing the code
          3. Adding more objects
          4. Solving a potential problem
      4. Important formulas in this chapter
          1. Conservation of momentum, in straight mathematical terms:
          2. Conservation of momentum in ActionScript, with a shortcut:
      5. Summary
    5. 12. PARTICLE ATTRACTION AND GRAVITY
      1. Particles
      2. Gravity
        1. Gravitational force
        2. Collision detection and reaction
        3. Orbiting
      3. Springs
        1. Gravity vs. springs
        2. A springy node garden
        3. Nodes with connections
        4. Nodes with mass
      4. Important formulas in this chapter
          1. Basic gravity:
          2. ActionScript-friendly gravity implementation:
      5. Summary
    6. 13. FORWARD KINEMATICS: MAKING THINGS WALK
      1. Introducing forward and inverse kinematics
      2. Getting started programming forward kinematics
        1. Moving one segment
        2. Moving two segments
      3. Automating the process
        1. Building a natural walk cycle
        2. Making it dynamic
      4. Making it really walk
        1. Giving it some space
        2. Adding gravity
        3. Handling the collision
        4. Handling the reaction
        5. Screen wrapping, revisited
      5. Summary
    7. 14. INVERSE KINEMATICS: DRAGGING AND REACHING
      1. Reaching and dragging single segments
        1. Reaching with a single segment
        2. Dragging with a single segment
      2. Dragging multiple segments
        1. Dragging two segments
        2. Dragging more segments
      3. Reaching with multiple segments
        1. Reaching for the mouse
        2. Reaching for an object
        3. Adding some interaction
      4. Using the standard inverse kinematics method
        1. Introducing the law of cosines
        2. ActionScripting the law of cosines
      5. Important formulas in this chapter
          1. Law of cosines:
          2. Law of cosines in ActionScript:
      6. Summary
  10. IV. 3D ANIMATION
    1. 15. 3D BASICS
      1. The third dimension and perspective
        1. The z axis
        2. Perspective
          1. The perspective formula
          2. Perspective in ActionScript
      2. Velocity and acceleration
      3. Bouncing
        1. Single object bouncing
        2. Multiple object bouncing
        3. Z-sorting
      4. Gravity
      5. Wrapping
      6. Easing and springing
        1. Easing
        2. Springing
      7. Coordinate rotation
      8. Collision detection
      9. Important formulas in this chapter
          1. Basic perspective:
          2. Z-sorting:
          3. Coordinate rotation:
          4. 3D distance:
      10. Summary
    2. 16. 3D LINES AND FILLS
      1. Creating points and lines
      2. Making shapes
      3. Creating 3D fills
        1. Using triangles
      4. Modeling 3D solids
        1. Modeling a spinning cube
        2. Modeling other shapes
          1. Pyramid
          2. Extruded letter A
          3. Cylinder
      5. Moving 3D solids
      6. Summary
    3. 17. BACKFACE CULLING AND 3D LIGHTING
      1. Backface culling
      2. Depth sorting
      3. 3D lighting
      4. Summary
  11. V. ADDITIONAL TECHNIQUES
    1. 18. MATRIX MATH
      1. Matrix basics
      2. Matrix operations
        1. Matrix addition
        2. Matrix multiplication
          1. Scaling with a matrix
          2. Coordinate rotation with a matrix
          3. Coding with matrices
      3. The Matrix class
      4. Summary
    2. 19. TIPS AND TRICKS
      1. Brownian (random) motion
      2. Random distribution
        1. Square distribution
        2. Circular distribution
        3. Biased distribution
      3. Timer- and time-based animation
        1. Timer-based animation
        2. Time-based animation
      4. Collisions between same-mass objects
      5. Integrating sound
      6. Useful formulas
        1. Chapter 3
          1. Calculate basic trigonometric functions:
          2. Convert radians to degrees and degrees to radians:
          3. Rotate to the mouse (or any point):
          4. Create waves:
          5. Create circles:
          6. Create ovals:
          7. Get the distance between two points:
        2. Chapter 4
          1. Convert hex to decimal:
          2. Convert decimal to hex:
          3. Combine component colors:
          4. Extract component colors:
          5. Draw a curve through a point:
        3. Chapter 5
          1. Convert angular velocity to x, y velocity:
          2. Convert angular acceleration (any force acting on an object) to x, y acceleration:
          3. Add acceleration to velocity:
          4. Add velocity to position:
        4. Chapter 6
          1. Remove an out-of-bounds object:
          2. Regenerate an out-of-bounds object:
          3. Screen wrapping for an out-of-bounds object:
          4. Apply friction (the correct way):
          5. Apply friction (the easy way):
        5. Chapter 8
          1. Simple easing, long form:
          2. Simple easing, abbreviated form:
          3. Simple easing, short form:
          4. Simple spring, long form:
          5. Simple spring, abbreviated form:
          6. Simple spring, short form:
          7. Offset spring:
        6. Chapter 9
          1. Distance-based collision detection:
          2. Multiple-object collision detection:
        7. Chapter 10
          1. Coordinate rotation:
          2. Reverse coordinate rotation:
        8. Chapter 11
          1. Conservation of momentum, in straight mathematical terms:
          2. Conservation of momentum in ActionScript, with a shortcut:
        9. Chapter 12
          1. Basic gravity:
          2. ActionScript-friendly gravity implementation:
        10. Chapter 14
          1. Law of cosines:
          2. Law of cosines in ActionScript:
        11. Chapter 15
          1. Basic perspective:
          2. Z-sorting:
          3. Coordinate rotation:
          4. 3D distance: