MACROMEDIA FLASH MX 2004-USING COMPONENTS Use Manual page 690

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

Advertisement

The second usage example uses a dispatcher/listener event model. A component instance
(
buttonInstance
function, also called a handler, on a listener object (
a method with the same name as the event on the listener object; the method is called when the
event occurs. When the event occurs, it automatically passes an event object (
the listener object method. The event object has properties that contain information about the
event. You can use these properties to write code that handles the event. Finally, you call
addEventListener()
instance that broadcasts the event to register the listener with the instance. When the instance
dispatches the event, the listener is called.
For more information, see
Example
This example, written on a frame of the Timeline, sends a message to the Output panel when a
button called
buttonInstance
switch. The second line creates a listener object called
the
event on the listener object. Inside the function is a
click
event object that is automatically passed to the function (in this example,
message. The
target
this example,
buttonInstance
event object's
target
and passes it the
buttonInstance.toggle = true;
form = new Object();
form.click = function(eventObj){
trace("The selected property has changed to " + eventObj.target.selected);
}
buttonInstance.addEventListener("click", form);
The following code also sends a message to the Output panel when
The
handler must be attached directly to
on()
on(click){
trace("button component was clicked");
}
SimpleButton.emphasized
Availability
Flash Player 6 (6.0 79.0).
Edition
Flash MX 2004.
Usage
buttonInstance.emphasized
690
Chapter 6: Components Dictionary
) dispatches an event (in this case,
(see
EventDispatcher.addEventListener()
"EventDispatcher class" on page
is clicked. The first line specifies that the button act like a toggle
property of an event object is the component that generated the event (in
). The
SimpleButton.selected
property. The last line calls
event and the
click
form
) and the event is handled by a
click
listenerObject
415.
. The third line defines a function for
form
trace()
property is accessed from the
addEventListener()
listener object as parameters.
.
buttonInstance
) that you create. You define
eventObject
) on the component
statement that uses the
) to generate a
eventObj
from
buttonInstance
is clicked.
buttonInstance
) to

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

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash mx

Table of Contents