Help with staying on frame

I recently started my a new game where you move the cursor (controlled by the arrow keys) and you can select different modes n stuff. Basically identical to Gran Turismo 4 without the extreme depth. Anyways, everything’s working fine except for the fact that I can’t get it to stay on the frame which I want when you select “Buy a Car” mode. What happens is that if you try and select it, it shows the frame for as long as the Enter key is held. What I’m wondering is how to fix this so that once you select “Buy a Car” mode, it stays on the frame which I want it to.

(could not include .fla because it was too big)

Here’s the code on the “Buy a Car” MC:

onClipEvent(enterFrame){
if(this.hitTest(_root.cursor)){
if(Key.isDown(Key.ENTER)){
gotoAndStop(“carSelection”);
} else {
gotoAndStop(“buyCar”);
}
} else {
gotoAndStop(1);
}
}

allright then try this :slight_smile:


[FONT=Courier New][/FONT] onClipEvent(enterFrame){
 if(this.hitTest(_root.cursor)){
 if(Key.isDown(Key.ENTER)){
_root.gotoAndStop("carSelection");                                               
 } else {
_root.gotoAndStop("buyCar");
 }
 } else {
 gotoAndStop(1);
   }
 }
 

[FONT=Courier New][LEFT][COLOR=#000000]

and make sure u got the frames a


stop();

 [FONT=Courier New][LEFT]

[/LEFT]
[/FONT]

[/COLOR]
[/LEFT]
[/FONT]

hey ricer, i tried what u suggested. But now when you hover the cursor over the “Buy a Car” option, it doesnt even show up anything let alone display the frame…

edit: DARN! I missunderstood you… Uhh… yeah :(…

It’s very simple… you have that key press check in onEnterFrame event

so when you press enter it goes on that “carSelection” frame but immediately due to onEnterframe event it will go in else… causing to switch back to buycar frame…

get your Key down check code out from onEnterFrame… instead use key listener objects… check help on that…

if you want to confirm it… put trace above all gotoAndStop lines

kk thanks will do.

here you go… dont forget to check disable keyboad shortcuts in flash IDE when testing…

um no offense but how is knowing the keycodes of diff keys sposed to help me?

no offense but how do you expect to make a gt game without much AS knowledge… or the will to learn

something you get to figure out yourself :wink: