topical media & game development
actionscript-events-Game.ax
actionscript-events-Game.ax
[swf]
flex
package {
import flash.events.*;
import flash.utils.*; // Required for the Timer class
public class @ax-actionscript-events-Game extends EventDispatcher {
public static const GAME_OVER:String = "gameOver";
public function @ax-actionscript-events-Game () {
// Force the game to end after one second
var timer:Timer = new Timer(1000, 1);
timer.addEventListener(TimerEvent.TIMER, timerListener);
timer.start();
function timerListener (e:TimerEvent):void {
end@ax-actionscript-events-Game();
}
}
private function end@ax-actionscript-events-Game ():void {
// Perform game-ending duties (code not shown)...
// ...then ask ActionScript to dispatch an event indicating that
// the game is over
dispatchEvent(new Event(@ax-actionscript-events-Game.GAME_OVER));
}
}
}
(C) Æliens
27/08/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.