With example below an introduction of phases in flex is demonstrated. In flex there are three phases. capturing, targeting and bubbling. These phases are actually the periods in which the flex does different jobs regarding an event, such as detecting the event listener for handling the event, triggering and then re-detecting listeners in reverse order for handling the event again. Event listeners are the functions or the methods that we create in our applications and inside event listeners, we create event associated objects. Event retorts (responds) , inside those function in which the corresponding event object is made.
Now going one by one we first have capturing phase in which flex checks containers like VBox for the event listeners for handling the event inside them. Event listeners are either called or initialized inside the flex controls with click and initialize attributes respectively. In Targeting phase flex just triggers the event and in the Bubbling phase flex re-begins its search for listeners but in order opposite to that was in capturing phase.
.eventPhase property of event object is used to detect the current phase of event. This property by default allocates the numbers 1, 2 and 3 to the phases capturing, targeting and bubbling respectively. In the example, event current phase is detected inside different TextInput controls.
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: June 10, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles