You are previewing Macromedia® Flash™ MX ActionScript for Fun & Games.
O'Reilly logo
Macromedia® Flash™ MX ActionScript for Fun & Games

Book Description

Anyone with moderate Macromedia Flash experience who is looking to acquire or improve their understanding of ActionScript will find this book a valuable resource. Author Gary Rosenzweig is highly respected in the Macromedia community and pioneered the use of advanced programming techniques in Macromedia Flash. For this edition, he has updated the games from the previous edition and has added several new projects. Each chapter studies and then deconstructs a new type of game or gadget such as hunt and click games, catch and avoid games, or action and adventure games and the CD contains the project source code.

Table of Contents

  1. Copyright
    1. Dedication
  2. About the Author
  3. Acknowledgments
  4. We Want to Hear from You!
  5. Introduction
    1. What Is in This Book?
    2. Who Is This Book For?
      1. Animators
      2. Illustrators
      3. Programmers
      4. Flash 3 and Flash 4 Programmers
      5. Readers of the First Edition of This Book
      6. Web Home Page Owners
      7. Professional Web Site Developers
      8. Students
    3. What Should You Already Know?
    4. What Can You Do with This Book?
      1. Learn ActionScript
      2. Learn How to Create Games in Flash
      3. Stealing These Games
    5. The CD-ROM
    6. Conventions
    7. Updates and Communication
    8. Have Fun
  6. 1. Flash Elements Used to Make Games and Toys
    1. The Flash Interface
      1. The Main Flash Window
      2. Panels
      3. Menu Items
        1. File Menu
        2. Edit Menu
        3. View Menu
        4. Insert Menu
        5. Modify Menu
        6. Text Menu
        7. Control Menu
        8. Window Menu
        9. Reference Panel
    2. Creating Buttons
      1. The Button Timeline
      2. Button Example
    3. Creating Text
      1. Text Properties
      2. Dynamic Text
      3. Input Text
    4. Importing Media into Flash
      1. Bitmaps
      2. Sounds
    5. Organizing Your Movie
      1. The Library
      2. Frames
      3. Layers
      4. Scenes
      5. Off-Stage Area
    6. Finishing Your Movie
      1. Final Checklist
      2. Publishing
      3. Putting Flash on the Web
  7. 2. An Introduction to ActionScript
    1. Lesson 1: What Is ActionScript and Where Does It Go?
      1. Frame Scripts
      2. Button Scripts
      3. Movie Clip Scripts
    2. Lesson 2: Using the Actions Panel
    3. Lesson 3: Your First ActionScript Program
    4. Lesson 4: Controlling Flash Playback
    5. Lesson 5: Creating Buttons to Give the User Control
    6. Lesson 6: Animating with ActionScript
    7. Lesson 7: Letting the User Control Movie Clips
    8. Lesson 8: Using Variables
    9. Lesson 9: Performing Operations
    10. Lesson 10: Conditional Statements
    11. Lesson 11: Loops
    12. Lesson 12: Text and Strings
    13. Lesson 13: Creating Functions
    14. Lesson 14: Arrays
  8. 3. ActionScript Elements Used to Make Games and Toys
    1. Lesson 15: Controlling the Playback of a Movie Clip
    2. Lesson 16: Controlling the Properties of a Movie Clip
    3. Lesson 17: Dragging and Dropping Movie Clips
    4. Lesson 18: Movie Clips and Levels
    5. Lesson 19: Duplicating Movie Clips
    6. Lesson 20: Controlling Multiple Movie Clips
      1. Creating an “Actions” Movie Clip
      2. Event Handlers
    7. Lesson 21: Detecting Collisions
    8. Lesson 22: Using Movie Clips to Change What Is on the Screen
    9. Lesson 23: Accepting Keyboard Input
    10. Lesson 24: Playing Sounds
  9. 4. The Game-Creation Process
    1. Flash and Games
      1. Weaknesses
      2. Strengths
    2. Parts of a Game
      1. Loading Screen
      2. Splash Screen
      3. Instructions
      4. Backgrounds
      5. Game Over Screen
    3. How to Program
      1. Breaking Down Problems
      2. Good Programming Practices
      3. Debugging
      4. Testing
    4. Games and Legal Issues
    5. Altering the Games in This Book
      1. Changing the Graphics
      2. Altering the ActionScript
      3. Combining Games
    6. Top Pitfalls
      1. Movie Clip Names
      2. Linkage Properties
      3. Movie Clip Levels
      4. Forgetting the Underscore
      5. Splice and Slice
      6. Global and Local Variables
  10. 5. ActionScript Design Effects
    1. Expanding Buttons
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    2. Color Cycling Rotating Spiral
      1. Project Goal
      2. Approach
        1. The Color Object
        2. Transforming Colors
      3. Preparing the Movie
      4. Color Cycling and Rotation
      5. Loose Ends
      6. Other Possibilities
    3. Randomness and the Old Film Effect
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    4. Letter Movement
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    5. Cursor Trail
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    6. 3D Illusions
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
        1. Converting Coordinates
        2. Cube Corners
        3. Adding Edges
      5. Other Possibilities
  11. 6. Toys and Gadgets
    1. The Magic Crystal Ball
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    2. Music Jukebox
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Other Possibilities
    3. Analog Clock
      1. Project Goal
      2. Approach
        1. Using the Date Object
      3. Preparing the Movie
      4. Writing the Code
      5. Other Possibilities
    4. Lava Lamp
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
    5. The Game of Life
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
  12. 7. Construction Toys
    1. Drag-and-Drop Make-a-Fox
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
    2. Click-And-Switch Make-A-Fox
      1. Project Goal
      2. Approach
      3. Writing the Code
      4. Loose Ends
      5. Other Possibilities
    3. Sketchbook
      1. Project Goal
      2. Creating a Simple Drawing Program
      3. Creating a Complex Drawing Program
      4. Adding Clear and Print Buttons
      5. Loose Ends
      6. Other Possibilities
    4. Music Mixer
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    5. Dancing Fox
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
  13. 8. Hunt and Click Games
    1. Find-A-Fox
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    2. Whack-A-Fox
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    3. Shoot-A-Fox
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    4. Hunt-A-Fox
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
  14. 9. Catch and Avoid Games
    1. Apple Catch
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    2. Apple Letter Catch
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    3. River Rafting Game
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    4. Racing Game
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
  15. 10. Aim and Shoot Games
    1. Move and Shoot the Balloons
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    2. Aim and Shoot
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    3. Balloon Invaders
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
  16. 11. Ball-and-Paddle Games
    1. Wall Ball
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    2. Paddle Ball
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    3. Paddle Bricks
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    4. 3D Paddle Bricks
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
  17. 12. Quizzes and Word Puzzles
    1. Flash Quiz
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    2. Flash Trivia
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    3. Hangman
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    4. Cryptogram
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
  18. 13. Picture Puzzles
    1. Jigsaw Puzzle
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Other Possibilities
    2. Sliding Puzzle
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    3. Matching Game
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    4. Find the Picture
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
  19. 14. Brain Puzzles
    1. Memory Game
      1. Approach
      2. Preparing the Movie
      3. Writing the Code
      4. Loose Ends
      5. Other Possibilities
    2. Deduction
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    3. Pegs
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Other Possibilities
    4. Recursive Blocks
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
  20. 15. Casino and Card Games
    1. Slot Machine
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    2. Video Poker
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    3. Simple Blackjack
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    4. Pyramid Solitaire
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
  21. 16. Arcade Games
    1. Space Combat
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
    2. Space Rocks
      1. Project Goal
      2. Preparing the Movie
      3. Writing the Code
      4. Loose Ends
      5. Other Possibilities
    3. Maze Chase
      1. Project Goal
      2. Preparing the Movie
      3. Writing the Code
      4. Loose Ends
      5. Other Possibilities
    4. Moon Lander
      1. Project Goal
      2. Preparing the Movie
      3. Writing the Code
      4. Loose Ends
      5. Other Possibilities
    5. Platform Scroller
      1. Project Goal
      2. Approach
      3. Preparing the Movie
      4. Writing the Code
      5. Loose Ends
      6. Other Possibilities
  22. 17. Advanced Techniques
    1. Performance and Optimization
      1. Using Alternatives
      2. Benchmarking
      3. Choosing the Best Alternative
      4. Benchmarking ActionScript
    2. Loader Screens
      1. Building a Loader
      2. A More Advanced Loader
      3. Other Types of Loaders
    3. Copy Protection
      1. How and Why Games Are Stolen
      2. Preventing Your Game from Running Elsewhere
      3. How to Get Around Copy Protection
      4. More Methods of Protecting Yourself
    4. High Score Boards
      1. How High Score Boards Work
      2. The Perl Programs
      3. Demonstration High Score Movie
      4. Implementing High Scores in a Game
      5. High Score Board Issues
    5. Testing Flash Player Versions
      1. Getting the Player Version
      2. Requiring Versions
      3. Flash 6 Player Capabilities
  23. A. Internet Resources for the Flash Developer
  24. B. The History of Games
    1. From Senet to Space War
      1. The Evolution of Board Games
      2. War and Role-Playing Games
    2. From Space War to Pong
    3. From Pong to Pac-Man
    4. The Video Game Comes Home
    5. Games Invade Computers
    6. Web-Based Computer Games
    7. Further Reading
  25. Windows Installation Instructions
  26. Macintosh Installation Instructions
  27. Read This Before Opening the Software