Game Development Reference
In-Depth Information
private function dispatchFrameEvent():void {
dispatchEvent(new Event(currentLabel));
private function enumerateFrameLabels():void {
for each (var label:FrameLabel in currentLabels)
addFrameScript(label.frame-1, dispatchFrameEvent);
These two functions use the addFrameScript method to dispatch
events, whenever a frame label is hit. Combined with the listeners
in the constructor, events will be fired when the title screen, game
screen, and results screen are reached.
protected function setupTitle(e:Event):void {
title.addEventListener(Title.PLAY_GAME, playGame, false,
0, true);
title.addEventListener(Title.SHOW_RULES, showRules,
false, 0, true);
protected function showRules(e:Event):void {
var rules:RulesPanel = new RulesPanel();
rules.x = stage.stageWidth/2;
rules.y = stage.stageHeight/2;
protected function playGame(e:Event):void {
protected function mainMenu(e:Event):void {
When the title screen is reached, we attach listeners to it for two
events that are defined in the Title class: PLAY_GAME and SHOW_
RULES. When showRules is called, it creates a new RulesPanel
instance, positions it, and adds it to the Stage. The playGame
method does exactly what you
go to the frame
with the game in it. The mainMenu method will be used later to
return to the title screen, but it is included here for consistency.
protected function setupGame(e:Event):void {
game.init(_imageList[0], 3, 4);
setTimeout(game.startGame, 1500);
Search Nedrilad ::

Custom Search