我有一堆使用TweenLite动画的动画片段(下面的代码),但我想连续循环2到3次。我把它们放在一个函数中但似乎无法使它们循环。每个动画片段的起始位置都在此功能之前定义 - 下面的示例也是如此。
我出错的任何想法?小号
private var F_Apricot:Fruit_Apricot;
F_Apricot = new Fruit_Apricot();
addChild(F_Apricot);
F_Apricot.x=222;
F_Apricot.y=-189;
F_Apricot.scaleX=0.7;
F_Apricot.scaleY=0.7;
setChildIndex(F_Apricot, 2);
function fruitLoop():void {
TweenLite.to(F_Passion, 1.7, {blurFilter:{blurX:8}, delay:1, x:277, y:325, scaleX:0.7, scaleY:0.7, rotation:28, ease:Cubic.easeOut});
TweenLite.to(F_Black1, 1.7, {blurFilter:{blurX:8}, delay:1.2, x:238, y:305, scaleX:0.5, scaleY:0.5, rotation:58, ease:Cubic.easeOut});
TweenLite.to(F_Apricot, 1.7, {blurFilter:{blurX:8}, delay:1.5, x:303, y:305, scaleX:0.7, scaleY:0.7, rotation:47, ease:Cubic.easeOut});
TweenLite.to(F_Raspberry, 1.7, {blurFilter:{blurX:8}, delay:1.6, x:207, y:305, scaleX:0.4, scaleY:0.4, rotation:18, ease:Cubic.easeOut});
TweenLite.to(F_Black2, 1.7, {blurFilter:{blurX:8}, delay:1.7, x:314, y:305, scaleX:0.5, scaleY:0.5, rotation:28, ease:Cubic.easeOut});
TweenLite.to(F_Cherries, 1.7, {blurFilter:{blurX:8}, delay:2.1, x:288, y:247, scaleX:0.6, scaleY:0.6, rotation:38, ease:Cubic.easeOut});
TweenLite.to(F_Black3, 1.7, {blurFilter:{blurX:8}, delay:2.3, x:323, y:305, scaleX:0.4, scaleY:0.4, rotation:-8, ease:Cubic.easeOut});
TweenLite.to(F_Lime, 1.7, {blurFilter:{blurX:8}, delay:2.4, x:208, y:305, scaleX:0.5, scaleY:0.5, rotation:28, ease:Cubic.easeOut});
TweenLite.to(F_Mango, 1.7, {blurFilter:{blurX:8}, delay:2.7, x:205, y:355, scaleX:0.7, scaleY:0.7, rotation:-38, ease:Cubic.easeOut});
TweenLite.to(F_Black4, 1.7, {blurFilter:{blurX:8}, delay:2.9, x:188, y:305, scaleX:0.5, scaleY:0.5, rotation:-8, ease:Cubic.easeOut});
TweenLite.to(F_Raspberry1, 1.7, {blurFilter:{blurX:8}, delay:3, x:303, y:305, scaleX:0.4, scaleY:0.4, rotation:-8, ease:Cubic.easeOut});
}
fruitLoop();
答案 0 :(得分:0)
private var F_Apricot:Fruit_Apricot;
F_Apricot = new Fruit_Apricot();
addChild(F_Apricot);
F_Apricot.x=222;
F_Apricot.y=-189;
F_Apricot.scaleX=0.7;
F_Apricot.scaleY=0.7;
setChildIndex(F_Apricot, 2);
function fruitLoop():void {
TweenLite.to(F_Passion, 1.7, {blurFilter:{blurX:8}, delay:1, x:277, y:325, scaleX:0.7, scaleY:0.7, rotation:28, ease:Cubic.easeOut});
TweenLite.to(F_Black1, 1.7, {blurFilter:{blurX:8}, delay:1.2, x:238, y:305, scaleX:0.5, scaleY:0.5, rotation:58, ease:Cubic.easeOut});
TweenLite.to(F_Apricot, 1.7, {blurFilter:{blurX:8}, delay:1.5, x:303, y:305, scaleX:0.7, scaleY:0.7, rotation:47, ease:Cubic.easeOut});
TweenLite.to(F_Raspberry, 1.7, {blurFilter:{blurX:8}, delay:1.6, x:207, y:305, scaleX:0.4, scaleY:0.4, rotation:18, ease:Cubic.easeOut});
TweenLite.to(F_Black2, 1.7, {blurFilter:{blurX:8}, delay:1.7, x:314, y:305, scaleX:0.5, scaleY:0.5, rotation:28, ease:Cubic.easeOut});
TweenLite.to(F_Cherries, 1.7, {blurFilter:{blurX:8}, delay:2.1, x:288, y:247, scaleX:0.6, scaleY:0.6, rotation:38, ease:Cubic.easeOut});
TweenLite.to(F_Black3, 1.7, {blurFilter:{blurX:8}, delay:2.3, x:323, y:305, scaleX:0.4, scaleY:0.4, rotation:-8, ease:Cubic.easeOut});
TweenLite.to(F_Lime, 1.7, {blurFilter:{blurX:8}, delay:2.4, x:208, y:305, scaleX:0.5, scaleY:0.5, rotation:28, ease:Cubic.easeOut});
TweenLite.to(F_Mango, 1.7, {blurFilter:{blurX:8}, delay:2.7, x:205, y:355, scaleX:0.7, scaleY:0.7, rotation:-38, ease:Cubic.easeOut});
TweenLite.to(F_Black4, 1.7, {blurFilter:{blurX:8}, delay:2.9, x:188, y:305, scaleX:0.5, scaleY:0.5, rotation:-8, ease:Cubic.easeOut});
TweenLite.to(F_Raspberry1, 1.7, {blurFilter:{blurX:8}, delay:3, x:303, y:305, scaleX:0.4, scaleY:0.4, rotation:-8, ease:Cubic.easeOut});
if(timer.currentCount>3 ){
timer.stop()
}
}
var timer:Timer = new Timer( 1000 );
timer.addEventListener(TimerEvent.TIMER, fruitLoop )
timer.start()
答案 1 :(得分:0)
TweenLite有一个名为onComplete的参数,可用于触发下一个循环。
答案 2 :(得分:0)
如果您只需要重复几次运动(相对于永久),那么您可以使用“延迟”参数一次设置所有转换来控制何时发生的情况。确保将“overwrite”设置为false,以便发生所有链接转换,而不仅仅是最后一次转换。
伪代码:
TweenLite.to(obj, 500, x=0);
TweenLite.to(obj, 500, x=0, delay=500, overwrite=false);
TweenLite.to(obj, 500, x=100, delay=1000, overwrite=false);
TweenLite.to(obj, 500, x=0, delay=1500, overwrite=false);
TweenLite.to(obj, 500, x=100, delay=2000, overwrite=false);
TweenLite.to(obj, 500, x=0, delay=2500, overwrite=false);