Chapter 19. Advanced Event Programming
Previous chapters have touched upon custom events, and you may have already tried your hand at creating custom events. This chapter goes into detail about how events work and creating your own events, and provides some tips on handling events and guidelines for event usage.
Custom Events versus Standard Events
Since the Flex Framework relies so heavily on events, it is quite natural that your own programs should use events and, further, should use their own custom events.
Remember that the technology underlying Flex is the Flash Player. The Flash Player is an event-driven system. Flex simply makes its own custom events. Most of the events are found in the mx.events
package. The ItemClickEvent
used with DataGrid
and List
is a common example.
A "custom" event is a class that extends the flash.events.Event
base class. The class includes its own special types.
A custom event is useless without its own event type, as event types are how events are distinguished. The
Event
class has atarget
and acurrentTarget
property. Thetarget
property is set to the object that initially dispatches the event. ThecurrentTarget
property is the object that has just produced the event. For example, if a button is clicked deep within your application, thetarget
property will be the button. If you intercepted the event by placing aclick
event handler on a container that holds the button, thecurrentTarget
property will be that container.
You may be writing a component ...
Get Professional Adobe® Flex® 3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.