Need to load, use and unload a Keyboard Event Handler when Spacebar is pressed.
Good evening everyone!
I am building a live, operator-based Jeopardy game and need to manually leave an initial Splash Screen on Frame 1 ("HOME") by pressing the Space Bar instead of using a mouse click (Keyboard Event Handler not Mouse Event). The problem seems to be that the destination frame ("RESET") already has another Keyboard Event Handler that uses the Space Bar for something different. All of my major Keyboard Event Handler code is on frame 10 ("RESET") except for the following, which is on the static Splash Screen on frame 1 *"HOME").
Essentially I am trying to make the Space Bar do double-duty by creating then unloading the Event Handler. It's safe to assume it's not as easy as I hoped it would be...
The error messages refer to line 24, which is the line highlighted in red below:
| MAIN, Layer 'Actions', Frame 1, Line 24, Column 10 | 1021: Duplicate function definition. |
| MAIN, Layer 'Actions', Frame 1, Line 24, Column 10 | 1023: Incompatible override. |
... and here's the frame 1 code:
stage.addEventListener(KeyboardEvent.KEY_DOWN, startGame);
function startGame(event: KeyboardEvent.KEY_DOWN): void {
if (event.keyCode == 32 ) {
stage.removeEventListener(KeyboardEvent.KEY_DOWN,startGame);
this.gotoAndStop("RESET");
}
}
Thanks in advance!
