Real-World Flash Game Development: How to Follow Best Practices AND Keep Your Sanity / Edition 2

Paperback (Print)
Used and New from Other Sellers
Used and New from Other Sellers
from $1.99
Usually ships in 1-2 business days
(Save 96%)
Other sellers (Paperback)
  • All (13) from $1.99   
  • New (7) from $39.13   
  • Used (6) from $1.99   


Your deadline just got moved up. Your artist has never worked with Flash before. Your inner programmer is telling you that no OOP is a big Oops! Any Flash developer can share similar tales of woe. This book breaks down the process of Flash game development into simple, approachable steps. Never heard of a game loop before? No idea what a design pattern is? No problem! Chris Griffith gives you real-world expertise, and real-world code that you can use in your own games. Griffith has been building games in Flash long enough to know what works and what doesn't. He shows you what you need to know to get the job done. Griffith covers Flash for the everyday developer. The average Flash developer doesn't have luxurious timelines, employers who understand the value of reusability, or the help of an information architect to design a usable experience. This book helps bridge the gap for these coders who may be used to C++, Java, or C# and want to move over to Flash. Griffith covers real-world scenarios pulled from his own experiences developing games for over 10 years in the industry. The 2nd edition will include: completely new game examples on more advanced topics like 3D; more robust physics and collision detection; and mobile device coverage with Android platform development for us on phones and tablets. Also coverage of the new features available in Flash CS5, Flash Player 10.1, and AIR 2.0 that can be used for game development. The associated web site for the book: gets close to 1,000 visits a month. On the site, readers can find all the source code for the examples, news on industry happenings, updates and special offers, and a discussion forum to ask questions and share ideas.

Read More Show Less

Editorial Reviews

From the Publisher
"The book could be used as a course resource for advanced undergraduates or as a reference for experienced programmers who want to use Flash. The excellent companion website supplies all the code needed to build the examples, as well as a forum where questions can be posted and answered. The author frequently inserts commentary about best programming practices (what to do and what to avoid), which differentiates this book from many similar titles. Summing Up: Highly recommended. Upper-division undergraduate through researchers/faculty, two-year technical program students, and professionals/practitioners."— E. Bertozzi, Long Island University, CHOICE
Read More Show Less

Product Details

  • ISBN-13: 9780240817682
  • Publisher: Taylor & Francis
  • Publication date: 4/22/2011
  • Edition description: New Edition
  • Edition number: 2
  • Pages: 432
  • Product dimensions: 7.40 (w) x 9.60 (h) x 1.00 (d)

Read an Excerpt

Real-World Flash Game Development

How to Follow Best Practices and Keep Your Sanity
By Christopher Griffith

Focal Press

Copyright © 2012 Elsevier Inc.
All right reserved.

ISBN: 978-0-240-81769-9

Chapter One



A Little Groundwork 2 Common Game Types 2 Adventure 2 Action 3 Puzzle 3 Word Games 3 Strategy and Simulation 4 Role-Playing Game (RPG) 5 Vehicle Games 5 Board/Card-Based Games 5 General Development Terms 5 Pseudocode 6 Algorithm 6 Procedural Programming 7 Object-Oriented Programming (OOP) 7 Design Patterns 7 Classes 7 Public, Protected, Private, and Internal 8 Game-Specific Development Terms 9 Artificial Intelligence (AI) 9 Game Loop (or Main Loop) 9 Game View 10 Scrolling 10 Tile-Based Games 11 Flash Development Terms 11 Stage 11 Display Objects 11 Events and Listeners 11 Packages 12 Author Time, Compile Time, and Runtime 12 You Can Wake Up Now 12

A Little Groundwork

Before we get too far into Flash, it's important to lay a foundation for game development, so we understand the terminology that will be used throughout the rest of the book. Refer back to this chapter when you forget what a term means or how it applies in a particular situation. If you start to feel a little overwhelmed by all the long words and abstract concepts, don't worry! Game development (particularly efficient, well-executed development) is complicated, and there's nothing wrong in admitting it. Remember that anyone who has programmed a game has suffered the same anxieties and doubt. Like anything in life, it will require practice and real-world experience to become proficient in game development. So grab a cup of your favorite caffeine-infused beverage, and let's get started!

Common Game Types

There are many different types of games (and some games that pride themselves on being unable to be easily categorized), but most can be classified into one of the following genres.


Adventure-style games are typically story-driven and have one or more central characters. These games are perceived the most like movies (some have been known to have the production budget of one) and can rely heavily on dialogue, exploration, and logical problem solving to move the player through the narrative. Adventure games were especially popular during the late 1980s and early 1990s, with LucasArts and Sierra producing some of the finest examples of the genre. This game type has had a resurgence of sorts in Flash due to its art-driven production pipeline and the typically lower system requirements.


This category encompasses a large number of gameplay perspectives and subgenres, but usually action games consist of tests of players' dexterity, reaction time, and quick-wittedness under pressure. First-person shooters, side and vertical scrolling games, and fighting games all fall into the action genre. Flash lends itself very well to some of the subgenres of this category, particularly retrostyle action games such as Space Invaders or Super Mario Brothers.


Think Tetris, Bejeweled, Sudoku, and the list goes on. Games that involve logic, problem solving, pattern matching, or all of the above fall into this game type. Flash thrives in this genre for a couple of reasons. First, there's generally a lower amount of art needed for a simple puzzle game, meaning individual developers can often do it themselves. Second, the core casual gaming audience on the Web tends to be older and appreciate the generally slower pace of puzzle games.

Word Games

This category could be considered a subgenre of puzzles, but the approach to building them can be different enough that I thought they deserved their own space. Word searches, crossword puzzles, spelling games, and anagrams all belong to this genre. Flash is a popular medium for games of this type; for the same reasons, it is for other puzzle games as well.

Strategy and Simulation

I'm cheating a little by combining these two genres into one, but they share a number of common traits. Careful planning, resource management, and decision making, such as city planning or the creation of a large army, characterize strategy games. The level of minutia the player is expected to maintain usually defines a strategy or simulation game. Some games are so complex as to allow every possible option available to the player to be micromanaged. More casual strategy games, like most created in Flash, simplify gameplay by reducing the number of options available and focusing on a couple of main tasks. A popular example of the casual strategy subgenre is tower defense games, where the player must stop enemies from getting past their defenses using a variety of different weapons placed strategically.

Role-Playing Game (RPG)

RPGs are similar to adventure games, but they are normally defined more by the growth of the main character throughout the course of the game's story. Traditionally, RPGs take place in a fantasy setting and center around the player's statistical development, such as improving traits such as strength, intelligence, agility. The most popular recent incarnation of these games has been in massively multiplayer online RPGs (MMORPGs), where players compete against and collaborate with each other to develop their characters. Because of the social and Web-based aspects, a few Flash MMORPGs have begun to emerge. However, these games are typically costly and have long-development cycles, making them riskier ventures for companies and infeasible for individual developers.

Vehicle Games

These games are pretty self-explanatory; they revolve around the operation of a vehicle on land, in water, in air, or in space. Traditionally, these games are played from a first- or third-person perspective to achieve a sense of realism. Because of system requirements and the complexity of building a full 3D environment in Flash, most casual games in this genre feature a two-dimensional game view.

Board/Card-Based Games

Usually a digital incarnation of a real-world game, this category can consist of games such as chess, checkers, blackjack, and poker. Because of the low system requirements, Flash is a great platform for creating most board and card games, as is evidenced by the large number of casino-style game sites on the Web.

General Development Terms

Computer science is a difficult field of study and definitely not for everyone who simply wants to make games. However, a fundamental understanding of some of the core concepts of programming helps later when we're dissecting a game piece by piece. Yes it's dry and occasionally tedious sounding, but I promise that fun stuff will follow!


Pseudocode is nothing more than a standard language explanation of a series of programmatic steps, which is like a summary of your logic. Throughout some of the examples in this book, you'll find that I sometimes break down the logic in a game in pseudocode before typing any actual ActionScript. It is easy to get too caught up in the syntax of programming and overlook a flaw in the logic, so it is almost always simpler to break down a problem in English before tackling it as actual code. Often my pseudocode will become the foundation for the names of my functions and properties.


An algorithm is nothing more than a series of instructions and decisions that define the solution to a problem. They are not code or language specific, and therefore they make sense in plain English. For instance, an algorithm could be as straightforward as the process that takes place when a program sorts a list of words by their length. Here is what that might look like in pseudocode:

for all in wordlist sort by length

sort by length (word A, word B) if A.length > B.length return B else return A

Procedural Programming

Many earlier programming languages, such as BASIC or Pascal, were what are known as procedural languages. You can think of them in the abstract as programming a list of tasks or subroutines. They can be executed in any order, but all the commands are driven by one main logic controller, sometimes referred to as the "main loop." The examples in this book will be a combination of procedural programming techniques and the next kind, object-oriented programming.

Object-Oriented Programming (OOP)

Unlike procedural programming, where the focus is on a set of tasks to be executed, OOP is centered around the concept of "objects" interacting with each other. OOP can be a very complicated subject to understand fully, but suffice it to say that each object is a self-contained entity that has defining properties, can send and receive messages from other objects, and can process its own internal logic. For example, in OOP, a person would be one object and his or her friend another. The persons will share some components, both being people, but they will also have characteristics unique to themselves. They communicate to each other through messages in a common language. Some of the aspects of ActionScript work in an OOP manner, and I will cover those at length later on in this book.

Design Patterns

Much is talked about these days with regard to design patterns in software engineering. There are many lengthy explanations, with whole books devoted to the subject in abstract. For the purposes of this book, think of a design pattern as the template for your code. It is the blueprint by which you can structure a game as you program it, particularly from an object-oriented approach. There are many accepted design patterns in the industry, some of which work well for Flash game development, and some that don't really have a place here. In Chapter 5, I'll discuss the most effective patterns I've found when working in Flash and how to implement them.


In OOP, classes are pieces of code that act as the building blocks of objects. You can think of them as templates from which all the objects used in an application are derived. A class defines all the properties and functions (known as methods) of an object. Using classes in Flash is important for a number of reasons. First of all, defining your code in classes requires you to put more planning into how you structure your game. This is a good thing; not having clearly defined blueprints leads to second guessing and duplication of work later on. If a carpenter went to build a house with no plans from the architect other than a single drawing, he would either quit or have to improvise continually along the way. The result would be a very inconsistent, possibly uninhabitable house. I'll cover class structure extensively later on, as most or all of our development will be centered on their use. In the mean time, here is an example of a simple class defining a player in a game.

package {

import flash.display.MovieClip;

public class Player extends MovieClip {

public const jumpHeight:Number=10;//pixels public const speed:Number=15;//pixels per second

public var health:Number=100;//percent public var ammo:int=20;//units

public function Player() { //initialization } } }

Not all the codes may make sense at this point, but hopefully you can see that we've just defined a player character with a predefined jumping height and movement speed, and variables for how much health and ammo he has. Granted, this little bit of code alone won't do anything, but it does create a foundation upon which to build more functionality and features.

Public, Protected, Private, and Internal

The four prefixes you can give to the properties and functions inside your classes, also known as attributes, define what items are available from one class to the next. All of them are documented in Flash's Help files, but here's a quick summary:

• Public methods and variables are accessible from anywhere and are the foundation for how classes interact with each other; when one class extends another, all public methods and variables are inherited.

• Protected methods and variables are accessible only from inside their class and are inherited.

• Private methods and variables are accessible only from inside their class and are not inherited.

• Internal methods and variables are accessible from all classes within their package.


Excerpted from Real-World Flash Game Development by Christopher Griffith Copyright © 2012 by Elsevier Inc.. Excerpted by permission of Focal Press. All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.

Read More Show Less

Table of Contents

Chapter 1: Computer Science Isn't For Everyone

Chapter 2: The Best Tool for the Job

Chapter 3: A Plan is Worth a Thousand Aspirin

Chapter 4: //Comments FTW!

Chapter 5: The Least You Can Do vs An Architect's Approach

Chapter 6: Managing Your Assets/Working With Graphics

Chapter 7: Make it Move - ActionScript Animation

Chapter 8: Turn it Up to 11: Working with Audio

Chapter 9: Put the Video Back in "Video Game"

Chapter 10: XML and Dynamic Content

Chapter 11: Four Letter Words: M-A-T-H

Chapter 12: Don't Hit Me: Collision Detection Techniques

Chapter 13: Mix Up - A Simple Engine

Chapter 14: Bringing It All Together: A Platformer

Chapter 15: Marble Runner : Our First Mobile Game

Chapter 16: Air Hockey: A Multi-Touch, Multiplayer Tablet Game


Online Content:

Bonus Chapter: Squash 'Em If You've Got 'Em: The Bug Hunt

Bonus Chapter: On Your Guard

Bonus Chapter: Introduction to Mobile Development

Appendix A: Webcams and Microphones

Appendix B: Localization

Appendix C: JSFL is JavaScript For Lovers

Appendix D: Using AMFPHP with Games

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)