User Guide
TextField.onKillFocus 737
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() method to write the instance name of the text field to the log
file:
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 fired 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.
TextField.onKillFocus
Availability
Flash Player 6.
Usage
my_txt.onKillFocus = function(newFocus:Object){
// your statements here
}
Parameters
newFocus
The object that is receiving the focus.
Returns
Nothing.
Description
Event handler; invoked when a text field loses keyboard focus. The onKillFocus method receives
one parameter,
newFocus, which is an object representing the new object receiving the focus. If
no object receives the focus,
newFocus contains the value null.
Example
The following example creates two text fields called first_txt and second_txt. When you give
focus to a text field, information about the text field with current focus and the text field that lost
focus writes to the log file.
this.createTextField("first_txt", 1, 10, 10, 300, 20);
first_txt.border = true;
first_txt.type = "input";
this.createTextField("second_txt", 2, 10, 40, 300, 20);