S > Selection.setFocus

 

Selection.setFocus

Availability

Flash Player 5. Instance names for button and text fields only work in Flash Player 6.

Usage

Selection.setFocus("variablePath")

Parameters

variablePath A string specifying the path to the name of a variable associated with a text field.

Returns

An event.

Description

Method; focuses the editable text field associated with the variable specified by the variablePath. The variablePath parameter must be a string literal of the path to that variable. You can use dot or slash notation to specify the path. You can also use a relative or absolute path.

If a target path of a button instance is passed as the variablePath parameter, that button becomes the new focus. If a target path of a text field instance is passed as the variablePath parameter, that text field becomes the new focus. If null is passed, the current focus is removed.

If a button movie clip is passed to Selection.setFocus, it becomes the currently focused button. If a TextField object is specified, it becomes the current focus. If a Button object is specified, it becomes the currently focused button.

Example

The following example sets focus on a text field on the main Timeline that is associated with the myVar variable. The variablePath parameter is an absolute path, so you can call the action from any Timeline.

Selection.setFocus("_root.myVar");

In the following example, the text field associated with myVar is in a movie clip called myClip on the main Timeline. You can use either of the following two paths to set focus; the first is relative and the second is absolute.

Selection.setFocus("myClip.myVar");
Selection.setFocus("_root.myClip.myVar");