2014-02-08 25 views
1

所以基本上我想用一個textField做一個閃爍效果,其中時間將是1秒。我只有一個「粗暴」的代碼,我認爲它可以做得更容易,但是可以弄清楚如何使它循環。如何停止TweenLite以及如何重複TweenLite的功能

我只有這

private var myBlackText:TextField = new TextField(); 
    private var myRedText:TextField = new TextField(); 
    private var format:TextFormat = new TextFormat(); 

    public function Main() 
    { 
     this.addChild(myBlackText) 
     myBlackText.defaultTextFormat = new TextFormat('Verdana',20,0x000000); 
     myBlackText.x = 200 
     myBlackText.y = 200 
     myBlackText.text = "YOYO" 


     this.addChild(myRedText) 
     myRedText.defaultTextFormat = new TextFormat('Verdana',20,0xFF0000); 
     myRedText.x = 200 
     myRedText.y = 200 
     myRedText.text = "YOYO" 

     TweenLite.to(myRedText, 1, { alpha:0, onComplete:ShowRed }); 
     function ShowRed():void 
     { 
      TweenLite.to(myRedText, 1, { alpha:1, onComplete:HideRed }); 
     } 
     function HideRed():void 
     { 
      TweenLite.to(myRedText, 1, { alpha:0, onComplete:ShowRed }); 
     } 
     stage.addEventListener(MouseEvent.CLICK, onClick); 
    } 

    private function onClick(ev:MouseEvent):void 
    { 
     //how do I stop the TweenLite ???? 
    } 

回答

3

如果你只是想殺死補間,這是儘可能簡單。

TweenLite.killTweensOf(myRedText);//will kill all tweens of myRedText 

試試這個,如果你想讓它更簡單就行了。

TweenMax.to(myRedText, 1, {alpha:0, repeat:-1, yoyo:true}); 

解釋:

repeat=-1意味着重複,直到永遠。

yoyo=true手段做紅色的阿爾法從1-0和0-1

所以整個是1-0-1-0-1紅色的阿爾法...

+0

呵呵奇怪我怎麼沒有發現這到目前爲止,還沒有任何提示讓整個事情(循環效果)更令人滿意?在這Tweenlite – GregorII

+0

@GregorII有沒有像循環功能的東西我認爲效果是好的,你是什麼意思的'循環功能'? – Tim

+0

重複想要的效果,直到在舞臺上點擊。我發現這個'var myTween:TweenMax = new TweenMax(mc2,3,{y:200,repeat:2,repeatDelay:1,onComplete:myFunction});'如果我將** repeat **變量更改爲 - 1它重複這個永遠,但不知道熱給它2個alpha變量,所以它從0到1,然後從1到0 – GregorII