03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

A reference to the text field instance is passed as a parameter to the onScroller <strong>and</strong><br />

onChanged h<strong>and</strong>lers by the event source. You can capture this data by putting a parameter in<br />

the event h<strong>and</strong>ler method. For example, the following code uses txt as the parameter that is<br />

passed to the onScroller event h<strong>and</strong>ler. The parameter is then used in a trace statement to<br />

send the instance name of the text field to the Output panel.The parameter is then used in a<br />

trace() method to write the instance name of the text field to the log file.<br />

my_txt.onScroller = function(textfield_txt:TextField) {<br />

trace(textfield_txt._name+" scrolled");<br />

};<br />

Parameters<br />

listener:Object - An object with an onChanged or onScroller event h<strong>and</strong>ler.<br />

Returns<br />

Boolean -<br />

Example<br />

The following example defines an onChanged h<strong>and</strong>ler for the input text field my_txt. It then<br />

defines a new listener object, txtListener, <strong>and</strong> defines an onChanged h<strong>and</strong>ler for that object.<br />

This h<strong>and</strong>ler will be invoked when the text field my_txt is changed. The final line of code<br />

calls TextField.addListener to register the listener object txtListener with the text field<br />

my_txt so that it will be notified when my_txt changes.<br />

this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 100,<br />

22);<br />

my_txt.border = true;<br />

my_txt.type = "input";<br />

my_txt.onChanged = function(textfield_(xt:TextField) {<br />

trace(textfield_txt._name+" changed");<br />

};<br />

var txtListener:Object = new Object();<br />

txtListener.onChanged = function(textfield_txt:TextField) {<br />

trace(textfield_txt._name+" changed <strong>and</strong> notified myListener");<br />

};<br />

my_txt.addListener(txtListener);<br />

See also<br />

onChanged (TextField.onChanged h<strong>and</strong>ler), onScroller (TextField.onScroller<br />

h<strong>and</strong>ler), removeListener (TextField.removeListener method)<br />

614 ActionScript classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!