
Selection.onSetFocus() Listener Event
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
751
Selection.onSetFocus() Listener Event
invoked when a movie’s input focus changes
Flash 6
Selection.onSetFocus(oldFocus, newFocus)
Arguments
oldFocus The Button, MovieClip,orTextField object that previously had focus, or null
if no object was previously focused.
newFocus The Button, MovieClip,orTextField object that now has focus, or
null if no
object is currently focused.
Description
The onSetFocus() event is triggered whenever input focus in a movie changes—for
example, when the user presses the Tab key to navigate from a form field to the form’s
Submit button. We can use onSetFocus() to manage input focus from a central location. To
handle focus for individual objects, we can alternatively use the Button, MovieClip,orText-
Field class’s onSetFocus() and onKillFocus() handlers, which are triggered only when focus
is given to or removed from a particular instance.
To respond to an onSetFocus() event, we must first assign a callback function to the
onSetFocus property of some object and then register that object as a listener. The
onSetFocus() callback should accept the
oldFocus and newFocus parameters, as follows:
// Create a generic object
selListener = new Object();
// Assign a callback function to the object's onSetFocus ...