
MovieClip.onSetFocus() Event Handler
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
690
|
ActionScript Language Reference
MovieClip.onSetFocus() Event Handler
callback invoked when the clip gains focus
Flash 6
mc.onSetFocus(oldFocus)
Arguments
oldFocus The TextField, MovieClip,orButton object that previously had focus, or null
if no object was previously focused.
Description
The onSetFocus() event handler is executed when mc gains focus. A clip gains focus when:
• The user navigates to the clip with the Tab key.
• Selection.setFocus() assigns focus programmatically.
A movie clip can be keyboard-focused under only one or more of the following
circumstances:
• It defines at least one button event handler (onPress(), onRollOver(), etc.).
• Its
tabEnabled property is true, in which case it can be focused by the Tab key.
• Its
focusEnabled property is true, in which case it can be focused by Selection.setFocus().
The following code registers a callback function that responds to onSetFocus():
// Assign the onSetFocus() callback using a function literal
theClip_mc.onSetFocus = function (newFocus) {
trace(this + " now has focus. Old focus was " + newFocus);
};
Notice that from the body of the callback, we can refer to theClip_mc using the this
keyword. To stop a callback from handling the onSetFocus() event, use the delete operator,
as in:
// Make sure ...