
Selection
1075
Example
The following example displays the currently focused selection's target path in a TextArea
component instance. Add several component instances or button, text field and movie clip
instances to the Stage. Add several component instances or button, text field and movie clip
instances to your SWF file. Then add the following ActionScript to your AS or FLA file.
var focus_ta:mx.controls.TextArea;
my_mc.onRelease = function() {};
my_btn.onRelease = function() {};
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.SPACE)) {
focus_ta.text = Selection.getFocus()+focus_ta.text;
}
};
Key.addListener(keyListener);
Test the SWF file, and use Tab to move between the instances on the Stage. Make sure you
have Control > Disable Keyboard Shortcuts selected in the test environment.
See also
onSetFocus (Selection.onSetFocus event listener)
,
setFocus
(Selection.setFocus method)
onSetFocus (Selection.onSetFocus event listener)
onSetFocus = function([oldfocus:Object], [newfocus:Object]) {}
Notified when the input focus changes. To use this listener, you must create a listener object.
You can then define a function for this listener and use Selection.addListener() to register the
listener with the Selection object, as in the following code:
var someListener:Object = new Object();
someListener.onSetFocus = function () {
// statements
}
Selection.addListener(someListener);
Listeners enable different pieces of code to cooperate because multiple listeners can receive
notification about a single event.
Availability:
ActionScript 1.0; Flash Player 6
Parameters
oldfocus
:Object
[optional] - The object losing focus.
newfocus
:Object
[optional] - The object receiving focus.
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...