Game Development Reference
In-Depth Information
game.addEventListener(Game.GAME_OVER, gameOver, false,
0, true);
protected function gameOver(e:Event):void {
var history:GameHistory = new GameHistory(true,
history.formattedTime =;
protected function setupResults(e:Event):void {
results.addEventListener(Results.PLAY_AGAIN, playGame,
false, 0, true);
results.addEventListener(Results.MAIN_MENU, mainMenu,
false, 0, true);
These three methods follow much the same pattern of doing
initialization, when a frame label is reached. The setupGame method
runs functions on the game object and adds a listener for the
GAME_OVER event. We
ll return to the gameOver method, later,
once we
ve progressed through the game logic that will get us there.
Suffice it to say that we
game in the history array. Now that the document class is defined,
ll store stats about the player
re ready to delve into each of the individual screens.
The Title Class
you directly into the action without explanation or pause. In this
example, we have only two options on the title screen, which keeps
it simple for explanation. A player can choose to start a game or
first view the rules.
public class Title extends MovieClip {
static public const PLAY_GAME:String =
static public const SHOW_RULES:String =
public var playButton:SimpleButton;
public var rulesButton:SimpleButton;
public function Title() {
addEventListener(Event.ADDED_TO_STAGE, addedToStage,
false, 0, true);
Search Nedrilad ::

Custom Search