MACROMEDIA FLASH 8-COMPONENTS LANGUAGE Reference page 1192

Components language reference
Table of Contents

Advertisement

The first usage example uses a dispatcher/listener event model. A component instance
(
) dispatches an event (in this case,
) and the event is handled by a
textAreaInstance
change
function, also called a handler, on a listener object (
) that you create. You
listenerObject
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 (
) to the listener object method. Each event object has properties that
eventObject
contain information about the event. You can use these properties to write code that handles
the event. Finally, you call the
method on the
EventDispatcher.addEventListener()
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
"EventDispatcher class" on page
499.
The second usage example uses an
handler and must be attached directly to a TextArea
on()
instance. The keyword
, used inside an
handler attached to a component, refers to
this
on()
the component instance. For example, the following code, attached to the instance
, sends "_level0.myTextArea" to the Output panel:
myTextArea
on (change) {
trace(this);
}
Example
This example uses the dispatcher/listener event model to track the total of number of times
the text area changes in a TextArea component named
.
my_ta
You must first add an instance of the TextArea component to the Stage and name it my_ta;
then add the following code to Frame 1.
/**
Requires:
- TextArea instance on Stage (instance name: my_ta)
*/
var my_ta:mx.controls.TextArea;
// Create a Number variable to track the number of changes to the TextArea.
var changeCount_num:Number = 0;
1188
TextArea component

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents