![]() ![]() ![]() | |
![]() | |
![]() | |
![]() |
Flash Player 6.
my_txt
.addListener(
listener
)
listener
An object with an onChanged
or onScroller
event handler.
Nothing.
Method; registers an object to receive notification when the onChanged
and onScroller
event handlers have been invoked. When a text field changes or is scrolled, the TextField.onChanged
and TextField.onScroller
event handlers are invoked, followed by the onChanged
and onScroller
event handlers of any objects registered as listeners. Multiple objects can be registered as listeners.
To remove a listener object from a text field, call TextField.removeListener()
.
A reference to the text field instance is passed as a parameter to the onScroller
and onChanged
handlers by the event source. You can capture this data by putting a parameter in the event handler method. For example, the following code uses txt
as the parameter that is passed to the onScroller
event handler. The parameter is then used in a trace
statement to send the instance name of the text field to the Output panel.
myTextField.onScroller = function (txt) { trace (txt._name + " changed"); };
The following example defines an onChange
handler for the input text field myText
. It then defines a new listener object, myListener
, and defines an onChanged
handler for that object. This handler will be invoked when the text field myText
is changed. The final line of code calls TextField.addListener
to register the listener object myListener
with the text field myText
so that it will be notified when myText
changes.
myText.onChanged = function (txt) { trace(txt._name + " changed"); }; myListener = new Object(); myListener.onChanged = function (txt) { trace(txt._name + " changed and notified myListener"); }; myText.addListener(myListener);
TextField.onChanged
, TextField.onScroller
, TextField.removeListener()
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |