开发者

Flex 3: How can i simulate the enter/return key being pressed

Title 开发者_如何学Gopretty much says it all... is there an easy way I can simulate the enter/return key being pressed?

EDIT:

I've got this much, but i'm not sure how to make it run in a loop:

var keyCode:uint = Keyboard.ENTER;
var e:KeyboardEvent = new KeyboardEvent(KeyboardEvent.KEY_DOWN, true, false, 0, keyCode);

I need it to run in the following loop:

for (var i:int = 0; i < changes.length; i++)
{
    if (changes[i][0] == "directorsPrep")
    {
        directorsPrep[changes[i][1]].phaseFillers[changes[i][2]].fillDisplayName.setFocus();
        // NEED IT TO RUN RIGHT HERE!
    }
}


for (var i:int = 0; i < changes.length; i++)
{
    if (changes[i][0] == "directorsPrep")
    {
        directorsPrep[changes[i][1]].phaseFillers[changes[i][2]].fillDisplayName.setFocus();
        // NEED IT TO RUN RIGHT HERE!
        // create the keyboard event; using your code
        var keyCode:uint = Keyboard.ENTER;
        var e:KeyboardEvent = new KeyboardEvent(KeyboardEvent.KEY_DOWN, true, false, 0, keyCode);
        // dispatch it    
        componentThatYouWantToDispatchKeyBoardEvent.dispatchEvent(e);
    }
}

The componentThatYouWantToDispatchKeyBoardEvent variable can be any component that extends EventDispatcher or implements IEventDispatcher.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜