user642523
user642523

Reputation: 151

How to loop timelinemax animation in this case

I have this code:

import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.events.*;

var timeline:TimelineMax = new TimelineMax({yoyo:true,repeat:1});
var timeline2:TimelineMax = new TimelineMax({repeat:0,delay:12});

timeline.appendMultiple([ 
 TweenLite.from(crno_mc, .2, {x:-450,ease:Cubic.easeInOut}), 
 TweenLite.from(plavo_mc, .2, {x:-450,ease:Cubic.easeInOut}),
     TweenLite.from(network_mc, .6, {x:-450,ease:Cubic.easeInOut}),
 TweenLite.from(computers_mc, .6, {x:-450,ease:Cubic.easeInOut}), 
     TweenLite.from(odzaci_mc, .6, {x:-450,ease:Cubic.easeInOut}),
 TweenLite.from(adresa_mc, 1, {x:-350,ease:Cubic.easeInOut}),
 TweenLite.to(adresa_mc, 1, {x:50,ease:Cubic.easeInOut}),
 ], 1, TweenAlign.SEQUENCE, .3);


timeline2.appendMultiple([
   TweenLite.to(krediti_mc, .2, {x:10,ease:Cubic.easeInOut}), 
   TweenLite.to(dodva_mc, .3, {x:10,ease:Cubic.easeInOut}),
   TweenLite.to(nula_mc, 1, {x:10,ease:Bounce.easeOut}),
       TweenLite.to(tel_mc, .6, {x:10,ease:Cubic.easeInOut}),
   TweenLite.to(comp_mc, 1, {x:110,ease:Cubic.easeInOut}), 
], 1, TweenAlign.SEQUENCE, .5);

How to loop this 2 tweens? When second animation finish, its stop.Is it posible to run one timeline after another in infinite loop ?

Tnx

Upvotes: 2

Views: 6511

Answers (2)

Jack
Jack

Reputation: 2970

You can nest timelines within timelines as deeply as you want, so you could simply append both of your timelines to a master timeline that has a repeat:-1 (which means repeat forever). Add this below your existing code:

var master:TimelineMax = new TimelineMax({repeat:-1});
master.append(timeline);
master.append(timeline2);

Upvotes: 8

Shefy Gur-ary
Shefy Gur-ary

Reputation: 658

Since you can calculate the time that you would finish the animation, you can use

delayedCall ()

You can also use onComplete var on the TweenLite.to function, see the documentation

Upvotes: 1

Related Questions