基本AS 3.0查询

发布于 2024-12-11 08:22:37 字数 31 浏览 1 评论 0原文

使用箭头浏览动作脚本 swf 的最佳方式是什么?

What is the best way to navigate through an actionscript swf using arrows?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黒涩兲箜 2024-12-18 08:22:37

设置 TextInputtabIndex 属性。这应该允许您通过选项卡浏览表单。

不建议覆盖箭头键的默认功能,因为它们用于移动 textInput 中的文本插入点

至于 Enter,您必须监听 keyUp 事件,如果检测到 Enter 键,则移动到下一个字段。

//add this eventlistener for each textbox (through a loop or manually)
t.addEventListener(KeyboardEvent.KEY_UP, k);

//The event handler
protected function k(e:KeyboardEvent):void {
    if(e.keyCode==Keyboard.ENTER) {
         focusManager.getNextFocusManagerComponent().setFocus();
    }
}

编辑

对于Flash CS5,此代码应该有效:

import flash.events.KeyboardEvent;
import fl.managers.FocusManager; 
import flash.display.InteractiveObject; 
import fl.managers.IFocusManagerComponent;
import fl.managers.IFocusManager;

t1.addEventListener(KeyboardEvent.KEY_UP, k);
t1.tabIndex=1;
t2.tabIndex=2;

var fm:FocusManager=new FocusManager(this);

t1.tabEnabled=true;
t2.tabEnabled=true;

function k(e:KeyboardEvent):void {
    if(e.keyCode==Keyboard.ENTER) {
         var fx:InteractiveObject = fm.getNextFocusManagerComponent();
         fm.setFocus(fx);
    }
}

重要:首先将一个组件从“用户界面”组拖到舞台上并将其删除。这应该将库中的所有必需组件准备好供您使用

EDIT2

for(var i:int=0; i < textbox.length; i++) {
        //textbox[i].buttonMode = true;
        //box[i].addEventListener(MouseEvent.CLICK, myclick_ftn);
        //box[i].addEventListener(FocusEvent.FOCUS_IN,textInputHandler);
        //box[i].addEventListener(FocusEvent.FOCUS_OUT,textInputHandlerOut);
        textbox[i].restrict = "0-9";
        textbox[i].addEventListener(KeyboardEvent.KEY_UP, k);
        textbox[i].tabIndex=i;
        //t2.tabIndex=2;

        //textbox[i].tabEnabled=true;

                var fm:FocusManager=new FocusManager(this);


        function k(e:KeyboardEvent):void {
            if(e.keyCode==Keyboard.ENTER) {
                var fx:InteractiveObject = fm.getNextFocusManagerComponent();
                fm.setFocus(fx);
    }
}
        //t2.tabEnabled=true;
}

代码更改为:

var fm:FocusManager=new FocusManager(this);


function k(e:KeyboardEvent):void {
    if(e.keyCode==Keyboard.ENTER) {
        var fx:InteractiveObject = fm.getNextFocusManagerComponent();
        fm.setFocus(fx);
    }
}

for(var i:int=0; i < textbox.length; i++) {
        //textbox[i].buttonMode = true;
        //box[i].addEventListener(MouseEvent.CLICK, myclick_ftn);
        //box[i].addEventListener(FocusEvent.FOCUS_IN,textInputHandler);
        //box[i].addEventListener(FocusEvent.FOCUS_OUT,textInputHandlerOut);
        textbox[i].restrict = "0-9";
        textbox[i].addEventListener(KeyboardEvent.KEY_UP, k);
        textbox[i].tabIndex=i;
        //t2.tabIndex=2;

        //textbox[i].tabEnabled=true; 

}

set the tabIndex property of the TextInput. That should allow you to tab through the form.

It is inadvisable to override the default functionality for arrow keys because they are used to move the text insertion point within the textInput

As for enter, you'll have to listen for the keyUp event and, if you detect an enter key, move to the next field.

//add this eventlistener for each textbox (through a loop or manually)
t.addEventListener(KeyboardEvent.KEY_UP, k);

//The event handler
protected function k(e:KeyboardEvent):void {
    if(e.keyCode==Keyboard.ENTER) {
         focusManager.getNextFocusManagerComponent().setFocus();
    }
}

EDIT

For Flash CS5, this code should work:

import flash.events.KeyboardEvent;
import fl.managers.FocusManager; 
import flash.display.InteractiveObject; 
import fl.managers.IFocusManagerComponent;
import fl.managers.IFocusManager;

t1.addEventListener(KeyboardEvent.KEY_UP, k);
t1.tabIndex=1;
t2.tabIndex=2;

var fm:FocusManager=new FocusManager(this);

t1.tabEnabled=true;
t2.tabEnabled=true;

function k(e:KeyboardEvent):void {
    if(e.keyCode==Keyboard.ENTER) {
         var fx:InteractiveObject = fm.getNextFocusManagerComponent();
         fm.setFocus(fx);
    }
}

important: first drag a component from the "User Interface" group onto the stage and delete it. This should put all the required components in the library ready for you to use

EDIT2

Change

for(var i:int=0; i < textbox.length; i++) {
        //textbox[i].buttonMode = true;
        //box[i].addEventListener(MouseEvent.CLICK, myclick_ftn);
        //box[i].addEventListener(FocusEvent.FOCUS_IN,textInputHandler);
        //box[i].addEventListener(FocusEvent.FOCUS_OUT,textInputHandlerOut);
        textbox[i].restrict = "0-9";
        textbox[i].addEventListener(KeyboardEvent.KEY_UP, k);
        textbox[i].tabIndex=i;
        //t2.tabIndex=2;

        //textbox[i].tabEnabled=true;

                var fm:FocusManager=new FocusManager(this);


        function k(e:KeyboardEvent):void {
            if(e.keyCode==Keyboard.ENTER) {
                var fx:InteractiveObject = fm.getNextFocusManagerComponent();
                fm.setFocus(fx);
    }
}
        //t2.tabEnabled=true;
}

in your code to this:

var fm:FocusManager=new FocusManager(this);


function k(e:KeyboardEvent):void {
    if(e.keyCode==Keyboard.ENTER) {
        var fx:InteractiveObject = fm.getNextFocusManagerComponent();
        fm.setFocus(fx);
    }
}

for(var i:int=0; i < textbox.length; i++) {
        //textbox[i].buttonMode = true;
        //box[i].addEventListener(MouseEvent.CLICK, myclick_ftn);
        //box[i].addEventListener(FocusEvent.FOCUS_IN,textInputHandler);
        //box[i].addEventListener(FocusEvent.FOCUS_OUT,textInputHandlerOut);
        textbox[i].restrict = "0-9";
        textbox[i].addEventListener(KeyboardEvent.KEY_UP, k);
        textbox[i].tabIndex=i;
        //t2.tabIndex=2;

        //textbox[i].tabEnabled=true; 

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文