AS2 OOP: Event Handling
         by senocular

Event Handling
With ActionScript 1.0, event handling was commonly handled through AsBroadcaster. AsBroadcaster is still available in ActionScript 2.0 (note the lowercase 's' when publishing to Flash 7 - using ASBroadcaster won't properly reference the object), but there's also a new object class that can replace AsBroadcaster which adds more functionality and and some new helpful behaviors. This is the EventDispatcher - a part of the object model implemented in the new Flash Components.

The complete EventDispatcher class is provided with Macromedia Flash MX 2004. It's defined in a folder in the Flash install directory so you are able to look it up if you wish to see how it works ( [Flash install]\[language]\First Run\Classes\mx\events ). I won't go into detail about it here, but if you know AsBroadcaster well enough, you should have no problem in using EventDispatcher. Included in that events directory are two other classes, UIEventDispatcher and LowLevelEvents can also be of use, even when not working specifically with components.

For more on using EventDispatcher, see The V2 Component Event Model Part 1- EventDispatcher from Phil Chung.

Though using EventDispatcher may be a nice alternative, you'll still maintain best performance when using AsBroadcaster.

 




SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple.