MACROMEDIA FLASH MX 2004-USING COMPONENTS Use Manual page 414

Using components
Hide thumbs Also See for FLASH MX 2004-USING COMPONENTS:
Table of Contents

Advertisement

EventDispatcher class
Events let your application know when the user has interacted with a component, and when
important changes have occurred in the appearance or life cycle of a component—such as its
creation, destruction, or resizing.
The methods of the EventDispatcher class let you add and remove event listeners so that your
code can react to events appropriately. For example, you use the
EventDispatcher.addEventListener()
instance. The listener is invoked when a component's event is triggered.
If you want to write a custom object that emits events that aren't related to the user interface,
EventDispatcher is smaller and faster to use as a mix-in for UIComponent than
UIEventDispatcher.
Event objects
An event object is passed to a listener as a parameter. The event object is an ActionScript object
that has properties that contain information about the event that occurred. You can use the event
object inside the listener callback function to access the name of the event that was broadcast, or
the instance name of the component that broadcast the event. For example, the following code
uses the
target
instance and send the value to the Output panel:
myButton
listener = new Object();
listener.click = function(evtObj){
trace("The " + evtObj.target.label + " button was clicked");
}
myButton.addEventListener("click", listener);
Some event object properties are defined in the W3C specification
Level-3-Events/events.html) but aren't implemented in version 2 of the Macromedia Component
Architecture. Every version 2 event object has the properties listed in the table below. Some events
have additional properties defined, and if so, the properties are listed in the event's entry.
Property
type
target
EventDispatcher class (API)
ActionScript Class Name
property of the
evtObj
Description
A string indicating the name of the event.
A reference to the component instance broadcasting the event.
mx.events.EventDispatcher
Components Dictionary
method to register a listener with a component
event object to access the
CHAPTER 6
property of the
label
(www.w3.org/TR/DOM-
EventDispatcher class
415

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx

Table of Contents