The Flex Event Model

by admin on June 11, 2008

Everything in Flex occurs based on an event. This means that simply clicking a button or key to moving the mouse or receiving a response from a web service provides developers with the ability to trigger a custom event in their Flex applications. That’s a lot of control, and since Flex is not based on the request/response model of a standard web app, the app contains the functionality to perform those custom events without ever leaving the web page. This is because events are client-based—in other words, separated from the request/response model of a web page and do not require the page to refresh with every user interaction.

Events enable an application to respond to an occurrence such as a certain variable value being achieved or the user clicking a certain button. They form an essential part of application development. Consider this straightforward example as the building blocks of Flex System and User Events combined in one small application.

[kml_flashembed movie="/flex/Essential Flex/bin-debug/handlingEvents.swf" height="300" width="550" /]
BREAK
When an event is triggered, there are three phases that flex uses to determine whether there are event listeners.

  • Capture phase: Flash Player checks every node from the root of the tree to the direct parent of the target node to see whether it has a listener registered to handle the event.
  • Target phase: The event is dispatched to the target node.
  • Bubbling phase: Flash Player carries out a check in a reverse manner with respect to that of the capturing phase (starting from the direct parent of the target node to the root of the tree).

Two types of events exist in Flex: System events are dispatched when the code is executed, and User events are dispatched when the user who is using the application interacts with the features of the application itself (for example, buttons, form elements, navigation controls).

{ 5 comments… read them below or add one }

Anand June 12, 2008 at 6:29 am

Hi,

Good stuff for beginners dude.

-Anand
(Adobe Certified Developer)

Reply

admin June 12, 2008 at 11:11 am

Agreed Anand..as you said some who claim they are experts don’t know how an event propagates from its target to upper layers!

Reply

CialisOa July 16, 2008 at 7:36 pm

Nice Article

Reply

Comprar Cialis August 4, 2008 at 11:53 am

Useful post.

Reply

SamOnes October 2, 2008 at 7:46 am

Did you hear? Russian agressor attacks USA…
More info here: hotusanewx.blogspot.com

SHOKED!!

Reply

Leave a Comment