[AS3] Game Key Events Not Responding [SOLVED]

Subscribe to [AS3] Game Key Events Not Responding [SOLVED] 3 posts

avatar for evan999333 evan999333 322 posts
Flag Post

So I have been working on a game for awhile and decided that it would be a good time to take a break from the hard coding and make a simple menu.

After making the menu I ran into a strange problem. When I click my ‘start game’ button my keyboard controls in game do not work until I click somewhere on the swf player again. After that everything works but I do not know what is causing the file to not take in the key events until I click on it again.

Has anyone else had this problem or know how to fix it?

 
avatar for Khronosis Khronosis 130 posts
Flag Post

Someone else might have more of an explanation, but this basically means the focus is set on something other than the game object.

A quick-fix is using this when you start the game:

stage.focus = this;

 
avatar for evan999333 evan999333 322 posts
Flag Post

Yep that fixed it. I guess I see how this happened.

The play button was inside a movieclip that gets removed when the play button is pressed so the last thing clicked was the moveiclip (so the focus was the movieclip) that got removed.

Thanks a lot Khronosis!