简体   繁体   English

单击按钮后未触发ActionScript 3键盘事件

[英]ActionScript 3 keyboard event not firing after button click

I'm building a simple game in which you control the character with WASD keys. 我正在构建一个简单的游戏,您可以在其中使用WASD键控制角色。 When you die, you go to another frame that says you died and has a button to play the game again. 当您死亡时,您转到另一个框架,说您已经死亡,并且有一个按钮可以再次玩游戏。 When I click the button, it goes to the frame 1 again, but the keyboard events don't work unless I click once more on the screen. 当我单击按钮时,它将再次转到第1帧,但是除非再次在屏幕上单击,否则键盘事件将不起作用。 How can I solve this? 我该如何解决? Thanks in advance. 提前致谢。

在您的frame1上,尝试添加活动的listiner来设置焦点:

activate="this.setFocus()"

I couldn't get your question clearly. 我不清楚你的问题。 If once you click on that button it is working correctly right. 如果您单击该按钮,则它可以正常工作。 If the way which i have understood is correct there might be problem on your looping or condition. 如果我所理解的方法是正确的,则可能是您的循环或状态出现问题。 please let me know your coding here, I will try to resolve. 请在这里告诉我您的编码,我会尽力解决。 else check yourself the looping or condition on the frame1 or where you wrote your keybord event listener. 否则请检查自己在frame1上的循环或状况,或者在其中编写键盘事件监听器的位置。 I hope it will be usefull else please let me know i will give you another solution. 希望对您有所帮助,请让我知道,我将给您另一个解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM