Dispatcher
| Kind of class: | class |
|---|---|
| Inherits from: | none |
| Known subclasses: | |
| Classpath: | org.asapframework.events.Dispatcher |
| File last modified: | Sunday, 08 October 2006, 22:39:04 |
Base class that contains the EventDispatcher mix-in and initialization.
Usage:
For any class that is to dispatch events, and that does not extend MovieClip, extend this class.
For classes that do extend MovieClip, use org.asapframework.ui.EventMovieClip.
Example extending a class:
Example using this extended class, supposing it implements the Singleton pattern:
For classes that do extend MovieClip, use org.asapframework.ui.EventMovieClip.
Example extending a class:
import org.asapframework.events.Dispatcher; import org.asapframework.events.Event; class DataManager extends Dispatcher { public static var EVENT_XML_LOADED:String = "onXMLLoaded"; // call <i>super</i> to initialize EventDispatcher private function DataManager () { super; } private function handleXMLLoaded () { <b>dispatchEvent</b>(new Event(DataManager.EVENT_XML_LOADED)); } }
Example using this extended class, supposing it implements the Singleton pattern:
import org.asapframework.events.EventDelegate; DataManager.getInstance().addEventListener(DataManager.EVENT_XML_LOADED, EventDelegate.create(this, handleXMLLoaded));
Summary
Constructor
Instance properties
Constructor
Dispatcher
function Dispatcher (
)
Call super() in any extending class to initialize EventDispatcher.
If the constructor is public, the call to super can be left out since Flash calls it automatically.
If the constructor is public, the call to super can be left out since Flash calls it automatically.
Instance properties
addEventListener
addEventListener:Function
(read,write)
removeEventListener
removeEventListener:Function
(read,write)