A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Animation play problem!

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    25

    Animation play problem!

    Hello,

    I'm having a problem with my animation playing for one of my characters, I have a method which is constantly sending the que to play the animation. When i press a key the character accelerates and the animation plays fine, however as soon as i let go of the key and the character begins to decelerate on its own the current frame reverts back to 1 and stays on 1 until i accelerate again. I want it so that the animation continues to play from its current frame rather than reverting back. Here's the code, thanks!

    Code:
    public function moveSamurai():void{
    			if(samuraiXDirection == 1){
    				if(samuraiVelocity < Util.maxSpeed){
    					samuraiVelocity += Util.acceleration;
    				}
    			}
    			else if(samuraiXDirection == 2){
    				if(samuraiVelocity < Util.maxSpeed){
    					samuraiVelocity -= Util.acceleration;
    				}
    			}
    			if(samuraiYDirection == 1){
    				if(!isJumping){
    					jumpPower = 25;
    					isJumping = true;
    				}
    				if(isJumping){
    					samuraiYMove += jumpPower;
    					jumpPower -= 1;
    				}
    				if(jumpPower == 0){
    					isJumping = false;
    				}	
    			}
    			if(samuraiVelocity >= 0.5 || samuraiVelocity <= -0.5)
    				samuraiVelocity = samuraiVelocity * Util.speedDecay;
    			else samuraiVelocity = 0;
    			samuraiXPos += samuraiVelocity;
    			SamuraiChar.move(samuraiVelocity, samuraiYMove);
    		}
    Code:
    		public function move(x:Number, y:Number):void{
    			if(x > 0){
    				currentlyAttacking = false;
    				currentlyMoving = true;
    				facingLeft = false;	
    				samuraiChar.gotoAndStop(3);
    				trace("hit " + samuraiChar.character.currentFrame);
    				if(samuraiXPos < currentLevelWidth + (Util.PLAYABLE_WIDTH/2)){
    					if(moveToEdge){
    						samuraiChar.x += x;
    					}
    					samuraiXPos += x;
    				}
    			}
    			if(x < 0){
    				currentlyAttacking = false;
    				currentlyMoving = true;
    				facingLeft = true;
    				samuraiChar.gotoAndStop(4);
    				if(samuraiXPos > 0){
    					if(moveToEdge){
    						samuraiChar.x += x;
    					}
    					samuraiXPos += x;
    				}
    			}
    			if(x == 0)
    				currentlyMoving = false;
    			if(y > 0){
    				if(samuraiYPos >= Util.GROUND)
    					samuraiYPos += y;
    			}
    		}

  2. #2
    Senior Member
    Join Date
    Jul 2008
    Posts
    391
    I don't see a single play () or gotoAndPlay ().

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    25
    Quote Originally Posted by 5Five555 View Post
    I don't see a single play () or gotoAndPlay ().
    O i forgot to mention that its accessing a nested movieclip with the gotoAndStop(), gotoAndStop(1) = idle animation, gotoAndStop(2) RuncycleLeft etc etc

  4. #4
    Senior Member
    Join Date
    Jul 2008
    Posts
    391
    So frame 1 of this movieclip contains another movieclip which is the animation? Is the problem that the movieclip doesn't play its idle animation once you decelerate to a stop? I don't find your description very clear.

  5. #5
    Junior Member
    Join Date
    Sep 2011
    Posts
    25
    Ok, there is a main movieclip which holds all of the animations. Frame 1 of the main movieclip holds another movieclip which is the idle animation, frame 2 the left facing run animation, frame 3 the right facing run animation etc. The problem is once I stop pressing the movement keys and the character begins to slowly decelerate however instead of the running animation continuing to play until the character has stopped moving, it just stops on frame 1 of the run animation and keeps playing frame 1 of the run animation instead of cycling through the rest of the frames.

  6. #6
    Junior Member
    Join Date
    Sep 2011
    Posts
    25
    Ok nevermind I managed to fix the problem after testing some of the older versions to see the differences, thanks for the help though. RESOLVED.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center