# Help with staying on frame

**URL:** <https://forum.kirupa.com/t/help-with-staying-on-frame/185970>\
**Category:** Uncategorized\
**Created:** [April 18, 2006, 4:19am UTC](https://forum.kirupa.com/t/help-with-staying-on-frame/185970 "2006-04-18T04:19:26Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sensible](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@Sensible](https://forum.kirupa.com/u/Sensible)\
**Post date:** [April 18, 2006, 4:19am UTC](https://forum.kirupa.com/t/help-with-staying-on-frame/185970/1 "2006-04-18T04:19:26Z")

</div>

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);  
}  
}

---

<div class="post-metadata">

**Author:** ![ricer](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@ricer](https://forum.kirupa.com/u/ricer)\
**Post date:** [April 18, 2006, 5:25am UTC](https://forum.kirupa.com/t/help-with-staying-on-frame/185970/2 "2006-04-18T05:25:17Z")

</div>

allright then try this 🙂

```auto

[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

```auto

stop();

```

```
 [FONT=Courier New][LEFT]

```

[/LEFT]  
[/FONT]

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

---

<div class="post-metadata">

**Author:** ![Sensible](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@Sensible](https://forum.kirupa.com/u/Sensible)\
**Post date:** [April 18, 2006, 8:36am UTC](https://forum.kirupa.com/t/help-with-staying-on-frame/185970/3 "2006-04-18T08:36:24Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)\
**Post date:** [April 18, 2006, 9:53am UTC](https://forum.kirupa.com/t/help-with-staying-on-frame/185970/4 "2006-04-18T09:53:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![theflash](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/theflash/32/1221_2.png) [@theflash](https://forum.kirupa.com/u/theflash)\
**Post date:** [April 18, 2006, 9:56am UTC](https://forum.kirupa.com/t/help-with-staying-on-frame/185970/5 "2006-04-18T09:56:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sensible](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@Sensible](https://forum.kirupa.com/u/Sensible)\
**Post date:** [April 18, 2006, 10:06am UTC](https://forum.kirupa.com/t/help-with-staying-on-frame/185970/6 "2006-04-18T10:06:26Z")

</div>

kk thanks will do.

---

<div class="post-metadata">

**Author:** ![theflash](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/theflash/32/1221_2.png) [@theflash](https://forum.kirupa.com/u/theflash)\
**Post date:** [April 18, 2006, 10:36am UTC](https://forum.kirupa.com/t/help-with-staying-on-frame/185970/7 "2006-04-18T10:36:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sensible](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@Sensible](https://forum.kirupa.com/u/Sensible)\
**Post date:** [April 18, 2006, 10:44am UTC](https://forum.kirupa.com/t/help-with-staying-on-frame/185970/8 "2006-04-18T10:44:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [April 18, 2006, 10:49am UTC](https://forum.kirupa.com/t/help-with-staying-on-frame/185970/9 "2006-04-18T10:49:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![theflash](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/theflash/32/1221_2.png) [@theflash](https://forum.kirupa.com/u/theflash)\
**Post date:** [April 18, 2006, 12:51pm UTC](https://forum.kirupa.com/t/help-with-staying-on-frame/185970/10 "2006-04-18T12:51:11Z")

</div>

> [@Sensible](#):
>
> um no offense but how is knowing the keycodes of diff keys sposed to help me?

something you get to figure out yourself 😉
