# Next level via using 1 key? :S

**URL:** <https://forum.kirupa.com/t/next-level-via-using-1-key-s/265628>\
**Category:** programming\
**Created:** [July 10, 2008, 8:28pm UTC](https://forum.kirupa.com/t/next-level-via-using-1-key-s/265628 "2008-07-10T20:28:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amymation](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@Amymation](https://forum.kirupa.com/u/Amymation)\
**Post date:** [July 10, 2008, 8:28pm UTC](https://forum.kirupa.com/t/next-level-via-using-1-key-s/265628/1 "2008-07-10T20:28:04Z")

</div>

Hi guys, I have yet another problem!

I’ve been working on this really cool platform/adventure game and in this game to get to the next level you have to go through a door, but this door isn’t on the stage until you get the magical gem. Before you say, I have all of that sorted out it’s just I don’t know what code to use for when the door is on the stage and to get to the next level the character (instance: char) is on the door movieclip (instance: door) AND the player has to press the D key(68) to get to the next level.

My friend gave me this code to go inside of the players code:  
if(Key.isDown(68)){  
if(Math.abs(\_x-door.\_x)\<(door.\_width/2)){  
\_root.gotoAndStop(2)  
}  
}

But nothing happens?

Please could you reply a.s.a.p!

---

<div class="post-metadata">

**Author:** ![bluemagica](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@bluemagica](https://forum.kirupa.com/u/bluemagica)\
**Post date:** [July 11, 2008, 4:55am UTC](https://forum.kirupa.com/t/next-level-via-using-1-key-s/265628/2 "2008-07-11T04:55:40Z")

</div>

that code should work assuming you have level 1 on frame 1, and level 2 on frame 2 of your timeline…

if(Key.isDown(68) and char.hitTest(door.\_x,door.\_y,true))  
{  
this.gotoAndStop(“level 2”)  
}
