# Problem with Switch AS3

**URL:** <https://forum.kirupa.com/t/problem-with-switch-as3/310319>\
**Category:** flash\
**Created:** [June 7, 2010, 5:55pm UTC](https://forum.kirupa.com/t/problem-with-switch-as3/310319 "2010-06-07T17:55:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mariannenen](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@Mariannenen](https://forum.kirupa.com/u/Mariannenen)\
**Post date:** [June 7, 2010, 5:55pm UTC](https://forum.kirupa.com/t/problem-with-switch-as3/310319/1 "2010-06-07T17:55:14Z")

</div>

Hey there!

I have (as you can read from the title) a problem with a switch code. I am quite new to AS3, and i am trying to understand it all. I am making a platform game with a movie. The movie is a running person runn to left and right and jump.

I have used if and if else, but the problem with that is, that you can not use 2 buttens at the same time. I thought i could change that if i would use the “switch”. But now there is nothing happening, it only play’s the “stand”. Here is the code:

mcMain.gotoAndStop(‘stand’);

mcMain.addEventListener(Event.ENTER\_FRAME, moveChar);

function moveChar(event:Event):void {  
switch (moveChar) {  
case leftKeyDown :  
mcMain.x-=mainSpeed;  
mcMain.scaleX=-1;  
mcMain.gotoAndStop(‘walk’);  
break;  
case “rightKeyDown” :  
mcMain.x+=mainSpeed;  
mcMain.scaleX=1;  
mcMain.gotoAndStop(‘walk’);  
break;  
case (upKeyDown||mainJumping) :  
mainJump();  
mcMain.gotoAndStop(‘jump’);  
break;  
default :  
mcMain.gotoAndStop(‘stand’);  
break;  
}  
}

I would really thank you so much if you could help me with my problem.  
tnx
