View comments | RSS feed

onChanged (TextField.onChanged handler)

onChanged = function(changedField:TextField) {}

Event handler/listener; invoked when the content of a text field changes. By default, it is undefined; you can define it in a script.

A reference to the text field instance is passed as a parameter to the onChanged handler. You can capture this data by putting a parameter in the event handler method. For example, the following code uses textfield_txt as the parameter that is passed to the onChanged event handler. The parameter is then used in a trace() statement to send the instance name of the text field to the Output panel:

this.createTextField("myInputText_txt", 99, 10, 10, 300, 20);
myInputText_txt.border = true;
myInputText_txt.type = "input";

myInputText_txt.onChanged = function(textfield_txt:TextField) {
trace("the value of "+textfield_txt._name+" was changed. New value is: "+textfield_txt.text);
};

The onChanged handler is called only when the change results from user interaction; for example, when the user is typing something on the keyboard, changing something in the text field using the mouse, or selecting a menu item. Programmatic changes to the text field do not trigger the onChanged event because the code recognizes changes that are made to the text field.

Availability: ActionScript 1.0; Flash Player 6

Parameters

changedField:TextField - The field triggering the event.

See also

TextFormat, setNewTextFormat (TextField.setNewTextFormat method)


Version 8

Comments


Fumio Nonaka said on Oct 11, 2005 at 7:00 PM :
I do not think that the onChanged handler is called when the user is just
selecting a menu item.

[Wrong]:
for example, when the user is typing something on the keyboard,
changing something in the text field using the mouse, or selecting a
menu item.

[Correct]:
for example, when the user is typing something on the keyboard, or
changing something in the text field using the mouse or selecting a
menu item.
swartz1999 said on Dec 16, 2005 at 5:21 PM :
Thanks for the suggestion, Fumio. Yes, you are correct, menu selection only invokes the onChanged handler when the menu command is related to changing the contents of the text field. (Removing the comma, as you suggest, makes a huge difference!)
N-J said on Apr 12, 2006 at 6:35 PM :
I have a text field into which the user must type a number, I then compare that number to determine if it is within certain parameters and act on it accordingly. I'm using on(Change) on the field to determine if the number has changed but the behaviour is very strange. If I type in '10' it is fine but if I select that and try to change it to '45' the '4' triggers a change which shows on a trace as '4' but the field is set to zero then when I type the '5' the zero remains in the display and the trace shows the new value as '05'. I don't want to use KillFocus because the focus isn't necessarily changed. How can I get a new multi-digit number into the field?

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00002761.html