Textfield.addlistener() - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

TextField.addListener()

Availability
Flash Player 6.
Usage
my_txt.addListener(listener:Object) : Void
Parameters
An object with an
listener
Returns
Nothing.
Description
Method; registers an object to receive notification when the
handlers have been invoked. When a text field changes or is scrolled, the
and
TextField.onScroller
event handlers of any objects registered as listeners. Multiple objects can be
onScroller
registered as listeners.
To remove a listener object from a text field, call
A reference to the text field instance is passed as a parameter to the
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
event handler. The parameter is then used in a
onScroller
name of the text field to the Output panel.
my_txt.onScroller = function(textfield_txt:TextField) {
trace(textfield_txt._name+" scrolled");
};
Example
The following example defines an
defines a new listener object,
This handler will be invoked when the text field
TextField.addListener
so that it will be notified when
this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 100, 22);
my_txt.border = true;
my_txt.type = "input";
my_txt.onChanged = function(textfield_txt:TextField) {
trace(textfield_txt._name+" changed");
};
var txtListener:Object = new Object();
txtListener.onChanged = function(textfield_txt:TextField) {
trace(textfield_txt._name+" changed and notified myListener");
or
onChanged
onScroller
event handlers are invoked, followed by the
handler for the input text field
onChanged
, and defines an
txtListener
to register the listener object
changes.
my_txt
event handler.
onChanged
TextField.removeListener()
onScroller
as the parameter that is passed to the
txt
statement to send the instance
trace
onChanged
is changed. The final line of code calls
my_txt
with the text field
txtListener
TextField.addListener()
and
event
onScroller
TextField.onChanged
and
onChanged
.
and
onChanged
. It then
my_txt
handler for that object.
my_txt
873

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx

Table of Contents