MACROMEDIA FLASH MX 2004-USING COMPONENTS Use Manual page 358

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

Advertisement

Usage 2:
listenerObject = new Object();
listenerObject.change = function(eventObject){
...
}
chooserInstance.addEventListener("change", listenerObject)
Description
Event; broadcast to all registered listeners when a date is selected.
The first usage example uses an
instance. The keyword
component instance. For example, the following code, attached to the date chooser
"_level0.myDC" to the Output panel:
on(change){
trace(this);
}
The second usage example uses a dispatcher/listener event model. A component instance
(
chooserInstance
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 is triggered. When the event is triggered, it automatically passes an event object
(
) to the listener object method. Each event object has properties that contain
eventObject
information about the event. You can use these properties to write code that handles the event.
Finally, you call the
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
DateChooser instance called
. The second line defines a function for the
form
function is a
trace()
function, in this example
object is the component that generated the event (in this example,
NumericStepper.maximum
line calls
EventDispatcher.addEventListener()
and the
listener object as parameters.
form
form.change = function(eventObj){
trace("date selected " +
}
myDC.addEventListener("change", form);
358
Chapter 6: Components Dictionary
handler and must be attached directly to a DateChooser
on()
, used inside an
this
) dispatches an event (in this case,
EventDispatcher.addEventListener()
"EventDispatcher class" on page
is changed. The first line of code creates a listener object called
myDC
statement that uses the event object that is automatically passed to the
, to generate a message. The
eventObj
property is accessed from the event object's
eventObj.target.selectedDate);
handler attached to a component, refers to the
on()
) and the event is handled by a
change
listenerObject
method on the component
415.
event on the listener object. Inside the
change
target
from
and passes it the
myDC
myDC
) that you create. You define
property of an event
). The
myDC
property. The last
target
event
change
, sends

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?

This manual is also suitable for:

Flash mx

Table of Contents