MACROMEDIA FLASH 8-COMPONENTS LANGUAGE Reference page 449

Components language reference
Table of Contents

Advertisement

The first usage example uses a dispatcher/listener event model. A component instance
(
dateFieldInstance
function, also called a handler, on a listener object (
define 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 (
eventObject
contain information about the event. You can use these properties to write code that handles
the event. Finally, you call the
component 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
The second usage example uses an
instance. The keyword
the component instance. For example, the following code, attached to the date field
sends "_level0.my_df " to the Output panel:
on (close) {
trace(this);
}
Example
The following example, written on a frame of the timeline, sends a message to the Output
panel when the date chooser in
called
. The second line defines a function for the
dfListener
object. Inside the function is a
automatically passed to the function, in this example
property of an event object is the component that generated the event—in this
target
example,
. The
my_df
property. The last line calls
it the
event and the
close
//Create listener object.
var dfListener:Object = new Object();
dfListener.close = function(evt_obj:Object){
trace("PullDown Closed" + evt_obj.target.selectedDate);
}
//Add listener object to DateField.
my_df.addEventListener("close", dfListener);
) dispatches an event (in this case,
) to the listener object method. Each event object has properties that
EventDispatcher.addEventListener()
"EventDispatcher class" on page
handler and must be attached directly to a DateField
on()
, used inside an
this
closes. The first line of code creates a listener object
my_df
statement that uses the event object that is
trace()
property is accessed from the event object's
selectedDate
EventDispatcher.addEventListener()
listener object as parameters.
dfListener
) and the event is handled by a
close
listenerObject
499.
handler attached to a component, refers to
on()
close
, to generate a message. The
evt_obj
) that you create. You
method on the
my_df
event on the listener
target
from
and passes
my_df
DateField.close
,
447

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-COMPONENTS LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents