Код AS3:
// документ класс
package {
import flash.display.*;
import flash.events.*;
public class Main extends Sprite {
private var game:Game;
public function Main() {
game = new Game();
addChild(game);
game.addEventListener(Game.BOOM,boomListener);
}
private function boomListener(e:Event):void{
trace("boom");
}
}
}
Код AS3:
// мой пользовательский класс который диспатчит событие
package {
import flash.display.*;
import flash.events.*;
public class Game extends Sprite {
public static const BOOM:String = "boom";
public var dispatcher:EventDispatcher;
public function Game() {
dispatcher = new EventDispatcher(this);
addEventListener(Event.ENTER_FRAME,enterFrameListener);
}
private function enterFrameListener(e:Event):void{
trace("enterFrame");
dispatcher.dispatchEvent(new Event(Game.BOOM));
}
}
}
вот код.