How to fire custom events in Actionscript-3?
I would like to add event listeners to my custom events similar to
stage.addEventListener(Keyboard.KEY_DOWN, myFunction);
My class is not inheriting and the event is LOADED like KEY_DOWN. When my
data is loaded I want to fire this event so every function that is
subscribed to this event can be notified about it:
public class MyClass
{
public static const LOADED: String = "Loaded";
public function addEventListener(eventType: String, handler:
Function):void
{
;
}
public function fireLoadedEvent(param: LoadedEvent):void
{
;
}
}
I would probably implement what I use in Flash to add event listeners but
in MyClass. I'm not sure how to store the listeners and how to call them
all with the parameters I want to pass to them. Is there something easier
and more common to use ?
No comments:
Post a Comment