
Selection.addListener() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
748
|
ActionScript Language Reference
to the Submit button, because rollover events occur before the button is pressed. For
example:
submit_btn.onRollOver = function () {
// Note which field is focused before the button is pressed.
focusedField = Selection.getFocus();
// Note which characters are selected.
beginIdx = focusedField.getBeginIndex();
endIdx = focusedField.getEndIndex();
}
By storing the focused field in a variable, we can then operate on the selected characters in
that field or return focus to the field after, say, checking the user’s input for errors.
See Also
The Button class, _focusrect, the MovieClip class, the TextField class
Selection.addListener() Method
register an object to receive onSetFocus() event notices
Flash 6
Selection.addListener(listener)
Arguments
listener An object with an onSetFocus() method defined.
Description
The addListener() method adds listener to the list of objects notified when Selection’s
onSetFocus() event occurs. The
listener argument is an object of any class that defines a
method by the name onSetFocus; the method is invoked when the onSetFocus() event
occurs for Selection. To stop a
listener object from receiving events, use Selection.
removeListener().
Multiple objects can respond independently to each onSetFocus( ...