Friday, December 18, 2009

Event.bubbles, Event.cancelable, and Event.currentTarget

Perhaps some of you may not know this, but event-bubbling in Actionscript3.0 is way cool and well worth your attention. So read on.
With event-bubbling you can let one Event subsequently call on every ancestor (containers of containers of etc.) of the DisplayObject that originally dispatched the Event, all the way up to the surface (read: Stage), hence the name 'bubbling'.Perhaps noteworthy is that bubbling for an Event instance is disabled by default, and can only be activated by setting the bubbling parameter in the Event constructor.
Although the documentation doesn't seem to make it all too apparent, event-bubbling is actually the reason why the Event class has a currentTarget property (as well as a target property).So what is the use of Event.currentTarget? While the target property will always have its value set to the DisplayObject that originally dispatched the Event, the currentTarget property always points to the DisplayObject that the event is currently processing (i.e. bubbling at).
Find out more here actual source

No comments:

Freelance