Help with possible mouseEvent/Keyboard Event problem
Hi guys, I am having trouble with a game I am creating right now. The problem seems to lie on mouse / Keyboard event.
Basically, I have a character that the player can control using the keyboard arrow keys and it works perfectly fine on its own. Whenever the game starts, the player can control the character instantly with the keyboard. Here's the problem now, after I added another page (at frame 1) and created a start game button, those keyboard events won't start immediately anymore. The player must click on the stage again before it works. Is there any method to solve this?
Right now, here is my Start button page.
var start_btn:Start_btn = new Start_btn;
start_btn.addEventListener (MouseEvent.CLICK, goGame);
function goGame(event:MouseEvent) {
gotoAndStop("game"); //The game's frame
this.removeEventListener(MouseEvent.CLICK,goGame);
}
Here's some code for the actual game part.
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyP ressed);
function keyPressed (e:KeyboardEvent) :void {
//character movement code...like charcter.x++, x-- etc
}
Thanks in advance