I am not new to AS3 and Flash but new to Flash timeline animations and controlling them with AS3. Had posted a similar question last week but the solution did not work. Hope someone could help me out here.

I am trying to control two different animations separately for one of my horse gameobjects inside the timeline through AS3.

For now, I have inserted really basic keyframes that hold all my animation frames. I have labelled them appropriately. Please look at the image below. These are not full animations, for now I am just playing around and testing it out.

enter image description here

I have named all the frames labels like "startwalk" "endwalk" "startTurnBack" and so on..

Now I want to control these animations and play them individually using AS3. I have added an enter_frame listener and started with a basic code as below but it does not seem to be working.

// this is the Event.ENTER_FRAME named gameLoop
private function gameLoop(event : Event) : void {
            trace(" current label " +horseTwo.currentLabel);
            var currLabel:String = horseTwo.currentLabel;
            var next:String;
            next = currLabel;
            if(currLabel == "endwalk"){

Nothing gets played. But if I do horseTwo.play(), it plays the animation throughout which is not what I want. I want to be able to control the keyframes via labels separately each for Walk, TurnBack and few more animations. Anyone got any ideas?


1 Answer 1


Put the horse animation on play and remove the horseTwo.gotoAndPlay(next); line from the event listener.

The problem is the horseTwo.gotoAndPlay(next); line. With that you are always returning to the beginning of the current label, end the animation never goes forward. The animation plays automatically when it is on play. So you dont need the var next:String; and next = currLabel; lines either. The event listener will stop it on label "endwalk".

In my test the code works with these changes.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .