Making MXML Interactive

MXML is useful for creating user interfaces—layout and controls. However, static content is not the hallmark of rich Internet applications. Users expect to be able to interact with Flex applications. There are two basic ways to create interactivity in MXML: handling events and data binding.

Handling Events

Every component does certain things. For example, at a minimum, all visual components can initialize themselves and resize. Most components can do things specific to that component type. For example, a button can respond to a user click. All of these things translate into something called an event. An event is a way that a component can notify other parts of the application when some action occurs. When a component sends out this notification, we say that it dispatches an event.

Note

The Flex event model is based on the W3C specification. (See http://www.w3.org/TR/DOM-Level-3-Events.)

In Flex all events are dispatched in the form of Event objects. Some events are a more specific type, meaning the event objects are actually instances of a subclass of the Event class. For example, when an Image component loads a file, it dispatches events of type ProgressEvent, which is a subclass of Event. Because all events are of type Event (or a subclass of Event), they all contain the same type of information, including the type of event (i.e., was it a click event or a progress event or an initialize event?) as well as what object dispatched the event. You’ll learn more ...

Get Programming 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.