KeyboardEvent is not dispatching event
Hi ![]()
I´m making a game.
This game has 4 frames.
It has a preloader.swf and game.swf.
The preloader.swf loads the game.swf.
The game.swf has 4 frames.
In the first frame is given to the user
the options to play the game (clicking a button "playGame"
on "click" event) and to set the sounds settings (clicking a button "options"
on "click" event).
So far so good.
The problem is:
When the user clicks "playGame" I send the user to frame 2,
where it has the option to select a game level using the arrow keys.
So within the playGameListener I registered two keyboard events one
for KEY_UP and another for KEY_DOWN.
So, to have sure that it´s working, I added a trace for each keyboard event
listener. But I´m not getting any message in the output window while pressing
left arrow or right arrow or any arrow.
So I learned that KeyboardEvent only dispatches an event if the flash player has focus.
Well I think the flash player has never losed focus in this process.
I´ve registered two events for Event.ACTIVATE and Event.DEACTIVATE and inside its listeners
I added a trace with a message.
Flash outputs me a message if I minimize the flash player window or if I maximize the flash player,
but not while the game.swf´s frame transition.
The listeners for the KeyboardEvent works only when I press at the flash player, then I receive the
messages from the KeyboardEvent listeners.
There´s any workaround for it?
I´m thinking to create an array with 4 places.
The first place would be for the "IntroScreen" movieclip, the second for the "LevelChooseScreen", and so on.
What do you think?
Thanks ![]()