MACROMEDIA FLASH 8-COMPONENTS LANGUAGE Reference page 1224

Components language reference
Table of Contents

Advertisement

The second usage example uses a dispatcher/listener event model. A component instance
(
textInputInstance
a 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
Example
This example creates a listener for a change event on the my_ti TextInput instance. When a
change event occurs, the example displays "Input has changed".
You must first drag a TextInput component to the Stage and give it an instance name of
; then add the following code to Frame 1.
my_ti
/**
Requires:
- TextInput instance on Stage (instance name: my_ti)
*/
var my_ti:mx.controls.TextInput;
// Create listener object.
var tiListener:Object = new Object();
tiListener.change = function(evt_obj:Object) {
trace("Input has changed");
};
// Add listener.
my_ti.addEventListener("change", tiListener);
See also
EventDispatcher.addEventListener()
1220
TextInput component
) dispatches an event (in this case,
) to the listener object method. Each event object has properties that
EventDispatcher.addEventListener()
"EventDispatcher class" on page
) and the event is handled by
change
) that you create. You
listenerObject
method on the
499.

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents