![]() ![]() ![]() | |
![]() | |
![]() | |
![]() |
Events allow a component to know when the user has interacted with the interface, and also to know when important changes have occurred in the appearance or life cycle of a component, such as the creation or destruction of a component or its resizing.
The event model is a dispatcher/listener model based on the XML Events specification. You write code that registers listeners with the target object so that when the target object dispatches an event the listeners are called.
Listeners are either functions or objects, but not methods. The listener receives a single event object as its parameter that contains the name of the event and includes all relevant information about the event.
Components generate and dispatch events and consume (listen to) other events. An object that wants to know about another object's events registers with that object. When an event occurs, the object dispatches the event to all registered listeners by calling a function requested during registration. To receive multiple events from the same object, you must register for each event.
Flash MX 2004 extends the ActionScript on()
handler to support component events. Any component that declares events in its class file and implements the addEventListener()
method is supported.
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |