This book takes you on a journey through the evolving art of Flash game programming. Each chapter discusses a key element of game programming, using Flash to create a variety of games.
Table of Contents
Macromedia Flash MX 2004 Game Programming
Part One - Getting Started
The Flash Authoring Tool
Part Two - Beginner Games
Programming Interactivity: Mouse Chaser
Creating Instances Dynamically: The Button Menu
Arrays: Match 'Em up and Sliders
Objects: Critter Attack
Part Three - Intermediate Games
Real-Time Programming: Shoot 'Em Up
Advanced Timing and Trigonometry: Blow 'Em Up
Object-Oriented Programming with as 2.0
Part Four - Advanced Games and Topics
Artificial Intelligence: Tic Tac Toe
Server-Side Support for Flash: Highscore Boards
ASCII Character Chart
Key Object Bindings
Web Resources and Further Reading
List of Figures
List of Tables
If you ve been searching for a tool that would allow you to create game-like applications with Web programming, you re not alone. Finally, that tool is available! Flash MX 2004 offers a complete programming solution that can be used to do much more than simply create cool Web sites. Macromedia Flash MX 2004 Game Programming will show you how you can take full advantage of this amazing programming tool. It offers an abundance of tips and techniques for programmers of all levels who want to learn how Flash technology can be used to create games. Each chapter discusses a key element of game programming, using Flash to create a variety of games . All the major areas of game development are covered ”from physics and artificial intelligence to collision detection and resolution.
About the Authors
Craig S. Murray began his career as a programmer at age 10 when he developed a Christmas tree with flashing lights. Twenty years later, Craig is still building software with an abundance of flashing lights. He teaches object-oriented design theory in Java and C++ at Indiana University/Purdue University ”Indianapolis, while starting a development company called Medusa Studios.
Justin Everett-Church is a Flash Developer specializing in Web games. Justin currently works for Yahoo! where he creates games and IMVironments for Yahoo! Messenger.
Copyright 2004 by Premier Press, a division of Course Technology.
All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system without written permission from Premier Press, except for the inclusion of brief quotations in a review.
The Premier Press logo and related trade dress are trademarks of Premier Press and may not be used without written permission.
SVP, Professional, Trade, and Reference Group: Andy Shafran
Publisher: Stacy L. Hiquet
Senior Marketing Manager: Sarah O'Donnell
Marketing Manager: Heather Hurley
Manager of Editorial Services: Heather Talbot
Senior Acquisitions Editor: Emi Smith
Associate Marketing Manager: Kristin Eisenzopf
Project Editor/Copy Editor: Karen A. Gill
Technical Reviewer: Chris Mancini
Retail Market Coordinator: Sarah Dubois
Interior Layout: Sue Honeywell
Cover Designer: Mike Tanamachi
CD Producer: Brandon Penticuff
Indexer: Kelly Talbot
Proofreader: Kate Welsh
Macromedia Copyright Notice: Copyright 2003. Macromedia, Inc., 600 Townsend Street, San Francisco, CA 94103 USA. All rights reserved.
Macromedia Trademark Notice: Macromedia and Flash MX 2004 are trademarks or registered trademarks of Macromedia, Inc. in the United States and/or other countries .
All other trademarks are the property of their respective owners .
Important: Premier Press cannot provide software support. Please contact the appropriate software manufacturer's technical support line or Web site for assistance.
Premier Press and the authors have attempted throughout this book to distinguish proprietary trademarks from descriptive terms by following the capitalization style used by the manufacturer.
Information contained in this book has been obtained by Premier Press from sources believed to be reliable. However, because of the possibility of human or mechanical error by our sources, Premier Press, or others, the Publisher does not guarantee the accuracy, adequacy, or completeness of any information and is not responsible for any errors or omissions or the results obtained from use of such information. Readers should be particularly aware of the fact that the Internet is an ever-changing entity. Some facts may have changed since this book went to press.
Library of Congress Catalog Card Number: 2003101218
Printed in the United States of America
04 05 06 07 08 BH 10 9 8 7 6 5 4 3 2 1
Premier Press, a division of Course Technology 25 Thomson Place Boston, MA 02210
For my mother.
”Craig S. Murray
To my parents and to Ray for their constant support.
Thanks to my father, who got me my first computer and my first bass guitar.
Thanks also to all my family, far and near, for being there when I needed you.
Thanks to Dr. Palakal, Michelle Boshears, and Jennifer Stewart for your belief in me and for the opportunities you have given me.
Special thanks to Andy Harris for getting me started as a teacher and writer. Your guidance has been invaluable.
Thanks to the wonderful team of professional people who helped me complete this book. This includes Justin Everett-Church, my technical editor; Karen Gill, my copy editor; Emi Smith, my acquisitions editor; and Andr LaMothe, the series editor.
Special thanks to Justin Everett-Church, whose hard work and attention to detail were amazing.
Thanks to my friends who keep my life amusing.
Finally, thanks to the Park Office for giving me shelter while I wrote this tome.
I'd like to thank Craig for bringing me in on this project in the first place.
Also, I'd like to thank my partner Ray for dealing with me even when I haven't slept.
Thanks to Mr. and Mrs. Dewberry. You two began my love of games , programming, and math.
Thanks to my co-workers at Yahoo!, especially Henri Torgemane, for listening and giving me advice.
Thanks to the folks on #flashhelp on EfNet. Where else could I go for Flash humor?
Finally, thanks to Tiki and Felix, who helped edit by jumping on the keyboard when I got too focused.
About the Authors
Craig S. Murray began his career as a programmer at age 10 when he successfully completed a project to develop a Christmas tree with flashing lights. The program was developed in AppleBasic and ran on his elementary school's brand-new Apple IIe computer. Twenty years later, Craig is still busy building software with an abundance of flashing lights. He has most recently been teaching object-oriented design theory in Java and C++ at Indiana University Purdue University at Indianapolis (IUPUI), while starting a development company called Medusa Studios . The company's Web site can be found at http://www.medusastudios.com.
Justin Everett-Church is a Flash developer specializing in Web games. Justin currently works for Yahoo!, where he creates games and shared environments for use in Yahoo! Instant Messenger. Outside of work, Justin teaches a course on ActionScript at Ohlone College and plays just about any game he can get his hands on. His Web site is http://www.infinitumdesign.com.
About the Artist
Rachel Cox has been drawing since she could hold a pencil. At a young age, she was introduced to her first computer, a Commodore 128. It was natural, as she grew older, to combine art and computers and become a digital artist. Rachel is currently a freelance graphic designer who illustrates fantasy art and belly dances in her spare time. Her Web site is http://www.orphicdesigns.com.
Letter from the Series Editor
If you're reading this text, then you probably already know that Macromedia's Flash technology has become a viable solution to create both online and standalone Web client-based games. Initially, Flash was nothing more than a curious technology similar to DHTML that allowed more control of the content within a Web site. This control was mostly in the form of real-time animations, transitions, and other "special fx."
However, the Flash technology has undergone numerous revisions, and now with the unveiling of Flash MX 2004, the Flash technology is a complete programming solution that can be used to do a lot more than simply create cool Web sites. Flash can and is used to create real-time 2D and 3D games that play from within the browser.
Web programmers and content creation experts have long wanted to create game-like applications with Web programming, but appropriate tools haven't been available. However, with Flash technology, games and more can be created without the huge technical and time investment needed to develop games with C/C++ and technologies such as DirectX.
Macromedia Flash MX 2004 Game Programming is the perfect start for both seasoned Flash programmers who are interested in learning how to use the technology to develop games and anyone who wants to learn how Flash technology can be employed to create games.
Craig Murray and Justin Everett-Church have taken a hands-on approach to this text; instead of discussing a lot of theory without example, they have used a more interactive methodology by which they introduce a concept with some fundamentals and then move directly into creating a game with the techniques. In this way, they reinforce the topic matter with realworld examples before moving on to the next subject.
The book starts off with an introduction to basic Flash MX technology and the interface and then moves on to programming with ActionScript.
Finally, it dives into graphics and gameplay. Each chapter discusses a key element of game programming using Flash as the platform for implementation. Techniques such as sound, input, graphics, AI, and even physics modeling are all covered.
Moreover, both authors are experts with years of experience with Flash from all its instantiations , so they know exactly where the rough spots are and can guide you safely to the other side!
In conclusion, as a C/C++ programmer myself , I get a little jealous that Flash MX can do so much, so easily. Maybe it's time for me to start making Flash games as well! But, no matter what your motivations are, you will find this book fascinating, timely , and technically sound. Furthermore, if you work through all the exercises and demos in the book, I guarantee you will be a Flash game programmer by the time you finish this book.