2011-05-04 88 views
0

我有一堆使用TweenLite動畫的動畫片段(下面的代碼),但我想連續循環它們2到3次。我已經把它們放在一個函數中,但似乎無法讓它們循環。每個動畫片段的起始位置都是在這個函數之前定義的 - 下面還有一個例子。Flash AS3循環mc的函數內部

任何想法我錯了嗎?小號

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

我看到每個水果的延遲是不同的。它們是否意味着全部同步循環,或者每個水果循環是否獨立於其他水果循環(即較早延遲的較短延遲循環)。 – 2011-05-04 16:57:10

+0

我會檢查出這種動畫的TimelineLite。您可以將時間線附加到每個補間,並等待整個動畫完成,並調用一個函數再次播放動畫(向前或向後)。 – Corey 2011-05-04 21:47:35

回答

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() 
0

如果你只需要運動重複幾次(相對於永遠的),那麼你可以設置一次全部使用「延遲」參數來控制的時候會發生什麼轉變。確保將「覆蓋」設置爲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);