O'Reilly logo

Professional Adobe® Flex® 3 by Joe Berkovitz, David Hassoun, Andrew Trice, Tom Sugden, Todd Prekaski, Jun Heider, Peter Ent, Joseph Balderson

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

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 a target and a currentTarget property. The target property is set to the object that initially dispatches the event. The currentTarget property is the object that has just produced the event. For example, if a button is clicked deep within your application, the target property will be the button. If you intercepted the event by placing a click event handler on a container that holds the button, the currentTarget property will be that container.

You may be writing a component ...

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