1168
ActionScript classes
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.
my_txt.onScroller = function(textfield_txt:TextField) {
trace(textfield_txt._name+" scrolled");
};
Availability:
ActionScript 1.0; Flash Player 6
Parameters
listener
:Object
- An object with an
onChanged
or
onScroller
event handler.
Returns
Boolean
-
Example
The following example defines an
onChanged
handler for the input text field
my_txt
. It then
defines a new listener object,
txtListener
, and defines an
onChanged
handler for that
object. This handler will be invoked when the text field
my_txt
is changed. The final line of
code calls
TextField.addListener
to register the listener object
txtListener
with the text
field
my_txt
so that it will be notified when
my_txt
changes.
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");
};
my_txt.addListener(txtListener);
The
MovieClip.getNextHighestDepth()
method used in this example requires Flash Player
7 or later. If your SWF file includes a version 2 component, use the version 2 components
DepthManager class instead of the
MovieClip.getNextHighestDepth()
method.
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...