AS3: Events
Apr 10th, 2008 by Leo Geis
If you’ve read our Event Framework post you should have a fundamental understanding of how Events in AS3 are structured. If you are just learning ActionScript 3, you’re probably ready for a little clarification on the organization of Event resources.
There are two Packages we’re concerned with presently: flash.events and flash.display.
Let’s review the flash.events Package:
The flash.events Package contains the EventDispatcher Class.
Note that the DisplayObject Class inherits from the EventDispatcher Class (it’s listed as a Subclass):
The very last statement in the above graphic is what we should focus on presently: The EventDispatcher Class, through inheritance, allows any Object on the Display List to be an Event Target-remember that an Event Target is the Object that makes the dispatchEvent() Call!
Let’s review the flash.display Package:
Sure enough, DisplayObject and DisplayObject Container are alive and well. What’s more:
DisplayObject has its own defined Events. The ASLR doesn’t offer an expanding menu selection (left pane) or itemization for inherited attributes-I’ve seen this cause a bit of confusion and wish that it would be changed to be more comprehensive (like the Actions Toolbox). Inherited attributes are identified well enough by the gray arrow and collapsing display in the main panel.
When you review the DisplayObjectContainer Class you’ll find that it has a number of inherited Events that DisplayObject does not offer. This can be confusing because it is easy to presume that DisplayObjectContainer has DisplayObject for a parent. Not so-those Events are defined by the InteractiveObject, which is the Subclass of DisplayObject and the Superclass of DisplayObjectContainer!
The flash.events Package contains a number of specific Event Classes:
The Event Class is, in Adobe’s words, “…the base class for the creation of Event objects, which are passed as parameters to event listeners when an event occurs.” I capitalize the proper names of OOP Objects to distinguish them from common use nouns and verbs-please don’t be confused by the absence of that convention in Adobe’s documentation.
You’ll note that there are also flash.events DataEvent, FocusEvent, KeyboardEvent, MouseEvent, ProgressEvent, TextEvent and TimerEvent Classes (et. al.), each of which offer a variety of Constants (all CAPITAL letters) that define Events.
Combined with the AS3 ability to define custom Events, these facilities provide a bewildering array of sources for usable Event Objects. The ASLR is a superb resource for exploration and reference while the Actions Toolbox is a simplified index for accessing them.
I trust this clarifies a number of issues concerning Events. A post dealing with how those resources are employed is already underway.








