O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Determining the Current Event Phase

As we learned in the earlier section "Registering an Ancestor Listener for Both the Capture Phase and the Bubbling Phase," by invoking addEventListener( ) twice, we can register a single event-listener function to be executed during both the capture phase and bubbling phases of an event dispatch. Similarly, in the section "The Dual Purpose of the useCapture Parameter," we learned that when an event listener is registered with useCapture set to false, that listener might be triggered during the target phase or during the bubbling phase of an event dispatch. Hence, when an event-listener function is executed in response to an event, the current event phase is not always known. Accordingly, ActionScript provides the Event class's instance variable eventPhase, which can be used within an event listener function to deduce the current event phase.

The eventPhase variable indicates whether the current event dispatch is in the capture phase, the target phase, or the bubbling phase. When the event dispatch is in the capture phase, eventPhase is set to EventPhase.CAPTURING_PHASE, indicating that the target object has not yet received event notification. When the event dispatch is in the target phase, eventPhase is set to EventPhase.AT_TARGET, indicating that the target object is currently processing the event. When the event dispatch is in the bubbling phase, eventPhase is set to EventPhase.BUBBLING_PHASE, indicating that the target object has finished processing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required