PDA

View Full Version : movieclip jump animation


Gaijin
08-31-2010, 02:15 PM
I am currently having a bit of trouble with a jumping animation that I am doing in actionscript 2.0

I have roughly 6 images that together make a relatively simple jumping sequence and each of the images is spread over 3 frames.

I have some code in the main scene that will make the character jump up into the air that works fine. It looks like this:

var mainJumping:Boolean = false;
var jumpSpeedLimit:Number = 15;
var jumpSpeed:Number = jumpSpeedLimit

onEnterFrame = function(){
if(!mainJumping){
if(Key.isDown(38) || Key.isDown(87)){
mainJumping = true;
jumpSpeed = jumpSpeedLimit*-1;
charMain.gotoAndPlay(4);
charMain._y += jumpSpeed;
}
} else {
if(jumpSpeed < 0){
jumpSpeed *= 1 - jumpSpeedLimit/75;
if(jumpSpeed > -jumpSpeedLimit*.2){
jumpSpeed *= -1;
}
}
if(jumpSpeed > 0 && jumpSpeed <= jumpSpeedLimit){
jumpSpeed *= 1 + jumpSpeedLimit/50;
}
charMain.gotoAndPlay(4);
charMain._y += jumpSpeed;
}
}

The only problem that I am having is with the lines that say charMain.gotoAndPlay(4). The main character reference is fine and works on the line below each of these references and the animation does go to frame 4, (which is the first frame of the second part of the animation), however it does not play the animation, just stops on the fourth frame.

The only code that I have in my movieclip is stop(); that is in the first frame of the clip so that when the player is not jumping the character animation is not working. :)

much appreciated.