开发者

Tabbing between fields - where does the cursor disappear to?

I am trying to create dynamic forms using AS3 in Flash CS5. The forms will be made up of a container sprite, and then pairs of TLFTextField objects, one for the caption (static, not selectable), and one for the input field itself.

I am using TLFTextField objects because I will be using the more开发者_JAVA技巧 powerful formatting capabilities of the this type in my final movie. Also, I'm not using text input components.

The form is created and shown as expected, however tabbing between the fields is not what I am expecting. If I enter text into the first field, I have to press the tab key 3 times to get to the second field, and 3 more times to get to the third, and so on.

I have tried setting tabChildren to true and false, and tried various combinations of enabling/disabling tabs for the TLFTextField objects, and manipulating the tabIndex sequences, all without success.

All help in solving this problem would be gratefully received.

For an illustration of the problem, create a new AS3 fla and add the following code to the first frame

import fl.text.TLFTextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFieldType;
import flash.display.Sprite;

stop();

var nIndex:Number = 0;
var yy:Number = 0;
var form:Sprite = new Sprite();
    form.tabChildren = true;

addTextField("First Name");
addTextField("Last Name");
addTextField("Age");

stage.addChild(form);

function addTextField(sCaption:String)
{
    addCaption(sCaption);
    var c:TLFTextField = new TLFTextField();
    c.autoSize = TextFieldAutoSize.NONE;
    c.y = yy;
    c.height = 20;
    c.width = 200;
    c.border = true;
    c.selectable = true;
    c.type = TextFieldType.INPUT;
    c.tabEnabled = true;
    // c.tabIndex = nIndex++;
    yy += 20;
    form.addChild(c);
}

function addCaption(sCaption:String)
{
    var c:TLFTextField = new TLFTextField();
    c.text = sCaption;
    c.autoSize = TextFieldAutoSize.LEFT;
    c.type = TextFieldType.DYNAMIC;
    c.tabEnabled = false;
    c.selectable = false;
    c.y = yy;
    yy += 20;
    form.addChild(c);
}

Thanks in advance

Andrew

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜