•
If a TextField object has focus, and the object has an instance name, this method returns the
target path of the TextField object. Otherwise, it returns the TextField's variable name.
•
If a Button object or button movie clip has focus, this method returns the target path of the
Button object or button movie clip.
•
If neither a TextField object, Button object, Component instance, nor button movie clip has
focus, this method returns
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 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()+newline+focus_ta.text;
}
};
Key.addListener(keyListener);
Test the SWF file, and use Tab to move between the instances on the Stage.
See also
Selection.onSetFocus,
Selection.onSetFocus
Availability
Flash Player 6.
Usage
someListener.onSetFocus = function( [ oldFocus:Object [, newFocus:Object ] ]){
// statements;
}
Parameters
The object losing focus. This parameter is optional.
oldfocus
The object receiving focus. This parameter is optional.
newfocus
Description
Listener; 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
register the listener with the Selection object, as in the following code:
var someListener:Object = new Object();
someListener.onSetFocus = function () {
674
Chapter 7: ActionScript for Flash
.
null
Selection.setFocus()
Selection.addListener()
to
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?