Copy link to clipboard
Copied
Suppose a MovieClip in as3 call myClip is 100 frames long and has labels at the following frames:
0-start; 25-early; 50-mid; 75-late; 100-end
Can someone explain (either using regular AS3 or with Greensock's TweenMax or TimelineMax) how to make my myClip play frames 0 to 25 then back to 0 again, and frames 100 to 75 and back to 100, Ideally would be able to loop over those ranges during a mouse ROLL_OVER event.
I'm pretty sure this can be done through Greensock's Tweening and Timeline platform, but can't quite get it working.
Thanks for any assistance.
Copy link to clipboard
Copied
Im not sure exactly what you are asking of, But you could have buttons so when the button is pressed it plays the 25 frames or so...
Copy link to clipboard
Copied
Using regular AS3 you could use an Event.ENTER_FRAME listener and have it call a function that uses either nextFrame() or prevFrame() function calls to move along the timeline. Each call could be preceded by a test to see if the destination frame == currentFrame, and when it does you remove the ENTER_FRAME listener
Copy link to clipboard
Copied
Thanks for the replies.
I saw the ENTER_FRAME method for doing this on a couple of google searches. Is there a way to make the MovieClip play in reverse with standard actionscript 3 - so if I can start at frame 0, go to frame 25, and then back to frame 0 when one button is rolled over, and from 100 to 75 and back to 100 for a different rollover?
I'm also pretty sure you can do this in a simpler fashion with Greensock's Tweenmax and / or TimelineMax. I'll try those forums as well. Do appreciate the help here as well. Thanks.
Copy link to clipboard
Copied
For backwards playing of an animation, you could always animate it that way. If you need an animation to loop within the timeline, you could simply add labels to frames and on the frame you desire tell it to gotoAndPlay(label).
However, if you need specifically to be able to play it forward and backward, then I would use what Ned said.
I am not sure you could do this within the timeline, you'd need to do this through AS3 class, by adding a ENTER_FRAME event that either told the MovieClip to do nextFrame() or prevFrame() depending on what you choose.
For example...
private const FORWARD:int = 0;
private const BACKWARD:int = 1;
private var action:int;
public function Constructor()
{
this.addEventListener(Event.ENTER_FRAME, animateMovieClip);
}
private function animateMovieClip(e:Event):void
{
switch (action)
{
case FORWARD:
this.nextFrame();
break;
case BACKWARD:
this.prevFrame();
break;
}
}
public function setAction(pAction:int):void
{
this.action = pAction;
}
This requires more logic, depending on your needs. However, I hope this gets you in the right direction.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now