标题几乎说明了一切......有一种简单的方法可以模拟按下的回车键吗?
编辑:
我有这么多,但我不知道如何让它循环运行:
var keyCode:uint = Keyboard.ENTER;
var e:KeyboardEvent = new KeyboardEvent(KeyboardEvent.KEY_DOWN, true, false, 0, keyCode);
我需要它在以下循环中运行:
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!
}
}
答案 0 :(得分:2)
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);
}
}
componentThatYouWantToDispatchKeyBoardEvent
变量可以是扩展EventDispatcher或实现IEventDispatcher的任何组件。