EventDispatcher, BroadcasterMX, OnEnterFrameBeacon, TransitionManager and Tween are some of the most useful classes that came bundled with Flash MX 2004. If nothing else, just reading the code can teach you a lot of coding techniques in AS2.
If you want to add event dispatching functionality to your app, and you want the client to have the ability to listen on a specific message you are dispatching, use the mx.event.EventDispatcher class. If you are interested in adding the ability to broadcast all messages to registered listeners, use mx.transitions.BroadcasterMX.
If you want your class to receive onEnterFrame, use mx.transitions.OnEnterFrameBeacon.
You can add these the broadcasting capabilities to your class like this:
class MyClass
{
static var _initBroadcaster = BroadcasterMX.initialize(MyClass.prototype, true);
// add function references so Broadcaster can decorate your class later
// by assiging the actual functions to these function references
public var addListener:Function;
public var removeListener:Function;
public var broadcastMessage:Function;
...
}
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home