Click to See Complete Forum and Search --> : Flash - Simple key problem
mollemus
05-18-2007, 05:39 AM
Hi!
I'm doing a simple flash-game, which has a title-screen,
an instruction-text screen, then the game-stage.
In order to get from the title-screen to the instructions
I want the player to press the Ctrl - key, no problem there.
But then at the next screen I want the player to press Ctrl
again to get to the game-stage. The problem is
that I use:
if (Key.isDown(Key.CONTROL)) {
gotoAndPlay("gamestage");
}
So if the player press Ctrl at the first screen, the flashmovie
just flips through the instructions and gets to the game directly
since the Ctrl-key is down.
How can I solve this problem?
Thx
Natdrip
05-18-2007, 05:43 PM
try gotoAndStop()
Kostas Zotos
05-18-2007, 06:46 PM
Hi,
One way could be to try the "Key.isDown" event to move from the "title-screen" to "instructions" and the "Key.isToggled" event to move fron the "instructions" to "gamestage" (so that the two events don't mixed)..
For example:
To go from the "title-screen" to "instructions" use the code:
if ( Key.isDown(Key.CONTROL)) gotoAndPlay ("instructions");
(Instead of "instructions" use your label name)
Then to go from the "instructions" to "gamestage" use the code:
if (Key.isToggled(Key.CONTROL)) gotoAndPlay ("gamestage");
----------------------------
In case movie clip instances are used (that is: the "title-screen", "instructions" and "gamestage" are 3 movie clip instances placed in the "_root"-main clip), then you may use the "onClipEvent (keyUp)" to navigate from clip to clip.
For example:
To go from the "title-screen" to "instructions" you can use the following code in the "title-screen" clip :
onClipEvent (keyUp) {
if (Key.getCode() == Key.CONTROL) _root.gotoAndPlay("instructions");
}
Note: in the '_root.gotoAndPlay("instructions")', "instructions" is the frame label in the _root (main) clip where the "instructions" clip is placed in the timeline (and where becomes visible). The same principle is also true for the "gamestage" below.
To go from the "instructions" to "gamestage" you can use the following code in the "instructions" clip :
onClipEvent (keyUp) {
if (Key.getCode() == Key.CONTROL) _root.gotoAndPlay("gamestage");
}
Regards
Kostas
mollemus
05-19-2007, 06:39 AM
Thx for the help!
I don't have 3 different movieclips so the first example worked fine!
hehe, the only problem now is that I counted wrong, I have
4 screens in total, title, intro, instructions and then game, so
it works for the first screen, go from title to intro, but then when I press
Ctrl again it jumps over instructions and start the game. Maybe I
should have different movieclips.