User Guide

420 Chapter 6: Components Dictionary
To create a button that receives focus when a user presses Enter (Windows) or Return
(Macintosh), set the
FocusManager.defaultPushButton property to the instance name of the
desired button, as shown here:
focusManager.defaultPushButton = okButton;
Note: The Focus Manager is sensitive to when objects are placed on the Stage (the depth order of
objects) and not their relative positions on the Stage. This is different from the way Flash Player
handles tabbing.
Using the Focus Manager to allow tabbing
You can use the Focus Manager to create a scheme that allows users to press the Tab key to cycle
through objects in a Flash application. (Objects in the tab scheme are called tab targets.) The
Focus Manager examines the
tabEnabled and tabChildren properties of the objects’ parents in
order to locate the objects.
A movie clip can be either a container of tab targets, a tab target itself, or neither:
Note: This is different from the default Flash Player behavior, in which a container’s tabChildren
property can be
undefined.
Consider the following scenario. On the Stage of the main Timeline are two text fields (txt1 and
txt2) and a movie clip (mc) that contains a DataGrid component (grid1) and another text field
(
txt3). You would use the following code to allow users to press Tab and cycle through the
objects in the following order:
txt1, txt2, grid1, txt3.
Note: The FocusManager and TextField instances are enabled by default.
// let Focus Manager know mc has children;
// this overrides mc.focusEnabled=true;
mc.tabChildren=true;
mc.tabEnabled=false;
// set the tabbing sequence
txt1.tabIndex = 1;
txt2.tabIndex = 2;
mc.grid1.tabIndex = 3;
mc.txt3.tabIndex = 4;
// set initial focus to txt1
txt1.text = "focus";
focusManager.setFocus(txt1);
If your movie clip doesnt have an onPress or onRelease method or a tabEnabled property, it
wont be seen by the Focus Manager unless you set
focusEnabled to true. Input text fields are
always in the tab scheme unless they are disabled.
Movie clip type tabEnabled tabChildren
Container of tab targets
false true
Tab target
true false
Neither
false false