This is a weird one. I have a run animation for a player with four states labeled on the timeline: idle (one frame with a stop(); call in the frame), start (which has no scripting in any frames), run (which has a gotoAndPlay(“run”); call on the last frame, and stop (which has a gotoAndStop(“idle”); call at the last frame).
When I call idle, startRun, or stopRun, things work as they should - the problem is when I call run. “run” is roughly 20 frames long, and the animation gets about halfway through before returning to the first frame and freezing. I have no idea why this is happening, but would be delighted if someone could tell me what I’m doing wrong.
Here’s my code:
package example
{
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.Event;
import flash.geom.Vector3D;
public class Player extends MovieClip
{
private var _netForce:Vector3D = new Vector3D();
private var _tempX:Number = 0;
private var _tempY:Number = 0;
public function get netForce():Vector3D
{
return _netForce;
}
public function set netForce(value:Vector3D):void
{
_netForce = value;
}
public function get isJumping():Boolean
{
if (_netForce.y < 0) return true;
return false;
}
public function set isJumping(value:Boolean):void { }
public function get isFalling():Boolean
{
if (_netForce.y > 0) return true;
return false;
}
public function set isFalling(value:Boolean):void { }
public function get tempX():Number
{
return _tempX;
}
public function set tempX(value:Number):void
{
_tempX = value;
}
public function get tempY():Number
{
return _tempY;
}
public function set tempY(value:Number):void
{
_tempY = value;
}
public function update():void { }
override public function get hitArea():Sprite
{
return this.hitBox;
}
public function leftStart():void
{
this.gotoAndPlay("run");
}
public function rightStart():void
{
this.gotoAndPlay("run");
}
public function stopRun():void
{
this.gotoAndPlay("stop");
}
}
}