如何重复TimelineLite时间轴的一部分

Fah*_*ter 1 actionscript-3 greensock

我正在使用Greensocks库'TimelineLite'进行补间.

我一直在寻找一个没有运气的解决方案.如何制作timelineLite的时间轴.假设我在时间轴内有10个补间,我想让3-10无限循环,前三个循环只有一个.

Boy*_*oyd 5

使用"onComplete:loop;"向tweenLite补间添加事件侦听器

var myTimeline:TimelineLite = new TimelineLite({onComplete:loop});
Run Code Online (Sandbox Code Playgroud)

在要启动循环的位置添加标签:

//Add a "spin" label 3-seconds into the timeline
myTimeline.addLabel("spin", 3);
Run Code Online (Sandbox Code Playgroud)

然后创建循环函数

function loop():void
{
  //go to the "spin" label and play the timeline from there
  myTimeline.gotoAndPlay("spin");
}
Run Code Online (Sandbox Code Playgroud)

编辑:或不必创建单独的loop功能:

var myTimeline:TimelineLite = new TimelineLite({
    onComplete: tl.gotoAndPlay,
    onCompleteScope: tl,
    onCompleteParams: ["spin"],
});
Run Code Online (Sandbox Code Playgroud)