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