Share Posted June 7, 2012 Hi all, I am sure this is something that is quite simple, however I am a newbie and would like to know how I loop the following code so that my animation keeps repeating. Would I need to rewrite the whole thing? I am new to actionscript, greensock is amazing! import com.greensock.*; import com.greensock.easing.*; //Train tween TweenNano.to(train, 0.75, {x:400, ease:Quad.easeOut}); //Rotation 1 text tween in TweenNano.to(mc, 1, {x:20, ease:Quad.easeOut}); //Rotation 1 text tween out TweenNano.to(mc, 1, {delay: 3, x:800}); //Destination text tween in TweenNano.to(destination,1, {delay: 4,x:20, ease:Quad.easeOut}); //Speed text tween in TweenNano.to(speed, 1, { x:235, delay: 4, ease:Quad.easeOut}); //Speed text tween out TweenNano.to(speed, 1, {delay: 7, x:800}); //Price text tween in TweenNano.to(price, 1, {delay: 7, x:240, ease:Quad.easeOut}); TweenNano.to(booknow, 1, {delay: 7,scaleX:1, scaleY:1, alpha:1}); Link to comment Share on other sites More sharing options...
Share Posted June 8, 2012 In order to have the animation loop, 2 things need to occur: 1: the initial starting positions of all of your objects need to be reset 2: the tweens need to be re-created. The easiest way to accomplish this is as follows: 1 - keep frame 1 of your timeline blank 2 - place your assets and animation code in frame 2 (be sure to add a stop() action) 3 - have your last TweenNano use an onComplete callback that advances the main timeline back to frame 1 where everything gets nuked and then when the playhead reaches frame 2 you assets will be back where they should start and the code will run fresh again. a simple cs4 fla/swf is attached import com.greensock.*; import com.greensock.easing.*; var delay:Number = 0; TweenNano.to(mc1, 1, {x:300}); delay += 1; TweenNano.to(mc1, 1, {scaleX:2, scaleX:2, delay:delay, overwrite:false}); delay += 1; TweenNano.to(mc2, 2, {x:400, delay:delay}); delay +=2 ; TweenNano.to(mc2, 2, {scaleX:.5, scaleY:.5, delay:delay, overwrite:false, onComplete:play}); stop(); if you don't want to jump between frames you would have to create a function that resets all the values of all the objects that are being tweened and have a second function that creates all the TweenNano tweens which can be quite a bit of work for elaborate sequences. TweenNanoLoop_CS4.zip 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now