Jump to content
Search Community

Simple loop AS2? How to?

dada78 test
Moderator Tag

Recommended Posts

The language you used was a little confusing - you mentioned tweening the x-coordinate but then "return to frame 1" which makes it sound like a frame tween - which is it? Keep in mind that you cannot mix ActionScript tweens and MovieClip timeline tweens (the ones you build in the Flash IDE). Once ActionScript edits any property of a MovieClip, it essentially "detatches" it from the timeline.

 

If you want to have a tween yoyo (go forwards and then backwards), TweenMax's yoyo and repeat properties make it super easy:

 

TweenMax.to(mc, 1, {_x:100, repeat:1, yoyo:true, repeatDelay:0.5});

 

If you want to use TweenLite, you can just use an onComplete to call a function that calls reverse() on the tween instance.

var tween:TweenLite = new TweenLite(mc, 1, {_x:100, onComplete:revertTween});
function revertTween():Void {
   TweenLite.delayedCall(0.5, tween.reverse);
}

Link to comment
Share on other sites

Hi, no all I meant was what I would like to accomplish is to create a continuous loop animation as if you would have animated a mc on from 1 at x:0 to frame 9 to x:100 for instance and have a "gotoAndPlay(1);" action on the last frame. I don't want to reverse an animation, I simply would like to have the animation start at the beginning after it has finished the first tween and to this forever.

 

Thanks,

C

Link to comment
Share on other sites

  • 3 months later...

im looking for something similar. i have a bunch of tweens and when it plays the last one i want it to go to the start again. what is the on complete code for this? if it is as above, where do i place this code. i tried placing it at the end, it didnt work.

 

thks in advance

Link to comment
Share on other sites

If you want to restart a bunch of tweens, I'd definitely recommend using a TimelineLite or TimelineMax. You just insert() or append() your tweens into one and then you can restart() the instance anytime. Or reverse() or change the timeScale, etc. If you're not familiar with TimelineLite/Max, check out the video at http://www.greensock.com/timeline-basics/

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...