在这种情况下如何循环timelinemax动画

时间:2012-08-02 11:57:05

标签: actionscript-3 loops tween tweenlite

我有这段代码:

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);

如何循环这2个补间?当第二个动画完成时,它会停止。是否可以在无限循环中运行一个又一个时间轴?

TNX

2 个答案:

答案 0 :(得分:7)

您可以根据需要在时间轴中嵌套时间轴,这样您就可以简单地将两个时间轴附加到具有repeat的主时间轴:-1(这意味着永远重复)。在现有代码下面添加:

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

答案 1 :(得分:1)

由于您可以计算完成动画的时间,因此可以使用

delayedCall()

您还可以在TweenLite.to函数上使用onComplete var,请参阅documentation