[英]Actionscript 3 keyboard not in focus?
I can't seem to move my Main_C using the keyboard. 我似乎无法使用键盘移动Main_C。 I do have a menu in the starting of the game.
游戏开始时我确实有一个菜单。 How can I make my keyboards work?
如何使键盘工作?
If you are in a Flex application, use the FocusManager. 如果您在Flex应用程序中,请使用FocusManager。 Assuming that "myMenuItem" is the object which should have focus:
假设“ myMenuItem”是应该具有焦点的对象:
focusManager.setFocus(myMenuObject);
If you are in an AS3 project: 如果您在AS3项目中:
stage.focus = myMenuObject;
Further on, if you want to move through the menu items, you may catch keyboard input to simulate a movement through the menu: 进一步,如果要在菜单项之间移动,可以捕获键盘输入以模拟通过菜单的移动:
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
private function keyDownHandler(event:KeyboardEvent):void {
trace(event.keyCode);
// Handle movement for corresponding arrow code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.