MACROMEDIA FLASH MX 2004-USING COMPONENTS Use Manual page 382

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

Advertisement

...
}
Usage 2:
listenerObject = new Object();
listenerObject.open = function(eventObject){
...
}
myDF.addEventListener("open", listenerObject)
Description
Event; broadcast to all registered listeners when a DateChooser subcomponent opens after a user
clicks on the icon.
The first usage example uses an
instance. The keyword
component instance. For example, the following code, attached to the date field
"_level0.myDF" to the Output panel:
on(open){
trace(this);
}
The second usage example uses a dispatcher/listener event model. A component instance (
dispatches an event (in this case,
handler, on a listener object (
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 (
object method. Each 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 the
EventDispatcher.addEventListener()
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
date field called
myDF
second line defines a function for the
statement that uses the event object that is automatically passed to the function, in this
trace()
example
, to generate a message. The
eventObj
component that generated the event—in this example,
property is accessed from the event object's
EventDispatcher.addEventListener()
listener object as parameters.
form.open = function(eventObj){
trace("Pop-up opened and date selected is " +
eventObj.target.selectedDate) ;
handler and must be attached directly to a DateField
on()
, used inside an
this
) and the event is handled by a function, also called a
open
listenerObject
method on the component instance that broadcasts
"EventDispatcher class" on page
is opened. The first line of code creates a listener object called
event on the listener object. Inside the function is a
open
target
from
handler attached to a component, refers to the
on()
) that you create. You define a method with the
415.
property of an event object is the
target
. The
myDF
DateField.selectedDate
property. The last line calls
and passes it the
myDF
DateField component (Flash Professional only)
, sends
myDF
) to the listener
eventObject
. The
form
event and the
open
)
myDF
form
383

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?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash mx

Table of Contents