Accept it, we all have used events but never really got to know what goes behind the scenes.
So here in vivid little words, I try to throw some light on this.
Here goes my “EVENTS for DUMMIES!”
Flash Player 9 implements an event model based on the World Wide Web Consortium’s (W3C) specification entitled Document Object Model Events available at http://www.w3.org/TR/DOM-Level-3-Events/events.html. According to this document, the lifecycle of an event that deals with display objects consists of three phases: capture, target, and bubbling.
You have probably heard of these names but never got to know why three phases are used??
The reason is simple.W3C recommends so! J
• Capture: During this phase, Flash Player makes a first pass to check every object from the root of the display list to the target component to see if any parent component might be interested in processing this event. By default, events are ignored by the parents of the target component at the capture phase. Its like collecting who and all are interested in the a components events.
If component 1 has a code like component2.addEventListener(“eventname”,myfunction);
Component 1 will be added to a list in this phase.
• Target: At this phase, event object properties are set for the target and all registered event listeners for this target will get this event.
Event.name and event.whatever is set now!
• Bubbling: Finally, the event flows back from the target component all the way up to the root to notify all interested parties identified during the capture phase. Not all events have a bubbling phase and you should consult the AS3 language reference for the events you’re interested in.
The three event phases described above don’t apply to the user-defined events because Flash Player 9 doesn’t know about parent-child relations between user-defined event objects. But AS3 developers can create custom event dispatchers, if they want to arrange event processing in three phases.
Hope it helps!