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.
精彩评论