Flash Lite 2.x and 3.0 ActionScript Language Reference

getFocus (Selection.getFocus method)

public static getFocus() : String

Returns a string specifying the target path of the object that has focus.

  • If a TextField object has focus, and the object has an instance name, the getFocus() method returns the target path of the TextField object. Otherwise, it returns the TextFields variable name.
  • If a Button object or button movie clip has focus, the getFocus() 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, the getFocus() method returns null.

Returns

String - A string or null.

Example

The following example creates a text field to output the path of the currently focused object. It then uses an interval function to periodically update the field. To test this, add several button instances to the stage with different instance names, and then add the following ActionScript to your AS or FLA file.

this.createTextField("status_txt", this.getNextHighestDepth(), 0, 0, 150, 25);

function FocusUpdate()
{
    s = Selection.getFocus();
    if ( s )
    {
        status_txt.text = s;
    }
}

setInterval( FocusUpdate, 100 );

See also

onSetFocus (Selection.onSetFocus event listener), setFocus (Selection.setFocus method)