Table of Contents

Button.onKillFocus( ) Event Handler Flash 6

callback invoked when the button loses focus
theButton.onKillFocus(newFocus)

Arguments

newFocus

The TextField, MovieClip, or Button object that now has focus, or null if no object has received focus.

Description

The onKillFocus( ) event handler is triggered when theButton loses focus. A button is said to "have focus" when:

When _focusrect is true or null (null is the default) a yellow rectangle appears around the focused button. A button loses focus when:

In the first two cases, onKillFocus( ) is executed. In the last case, due to a bug in Flash Player 6, onKillFocus( ) is not executed, but it should be. When a button's tabEnabled property is false, the button cannot be focused by the user but can be focused programmatically with Selection.setFocus( ). To capture all focus events centrally, rather than for a single instance, use Selection.onSetFocus( ).

Example

The following example adds callback handlers, for onSetFocus( ) and onKillFocus( ), to cancel_btn. It also creates a text field that displays the focus status. Finally, it focuses cancel_btn. To try the code, create two buttons, one called "cancel_btn". Then run the movie in the Standalone Player and press the Tab key (without touching the mouse!). If you test in a browser, you must first click the movie before pressing Tab.

this.createTextField("status_txt", 1, 0, 0, 300, 20);
status_txt.border = true;
   
cancel_btn.onKillFocus = function () {
  // Handle event...
  status_txt.text = ("killfocus detected for cancel_btn");
};
   
cancel_btn.onSetFocus = function () {
  // Handle event...
  status_txt.text = ("setfocus detected for cancel_btn");
};
   
Selection.setFocus(cancel_btn);

See Also

Button.onSetFocus( ), Selection.onSetFocus( ), Selection.setFocus( ), MovieClip.onKillFocus( ), TextField.onKillFocus( ); Chapter 10


Table of Contents