package { import flash.events.*; import flash.utils.*; // Required for the Timer class public class actionscript_events_Game extends EventDispatcher { public static const GAME_OVER:String = "gameOver"; public function 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 { endactionscript_events_Game(); } } private function endactionscript_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(actionscript_events_Game.GAME_OVER)); } } }