1

So basically I want to make a Blinking effect with a textField where the time will be 1 sec. I have only a "brut" code that I think it can be done easier but coundt figure out how to make it loop.

i have only this

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 ????
    }

1 Answer 1

3

If you only want to kill the tween, this is as simple as possible.

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

Try this if you want it be more simple in just on line.

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

Explain:

repeat=-1 means repeat forever.

yoyo=true means do Red's alpha from 1-0 and 0-1

So the whole is Red's alpha from 1-0-1-0-1...

5
  • huh strange how i didnt find this so far.10x, yet any hints how to make the whole thing (the loop effect) more eye-pleasing ? Is there something like a loop function in this Tweenlite
    – GregorII
    Feb 8, 2014 at 13:19
  • @GregorII I think the effect is ok, and what you mean by a loop function?
    – Tim
    Feb 8, 2014 at 13:29
  • to repeat the wanted effect until there is a click on the stage. i found this var myTween:TweenMax = new TweenMax(mc2, 3, {y:200, repeat:2, repeatDelay:1, onComplete:myFunction}); and if i change the repeat variable to -1 it repeats this forever but dont know hot to give it 2 alpha variables so it goes from 0 to 1 and then from 1 to 0
    – GregorII
    Feb 8, 2014 at 13:56
  • well ... what i found (the above comment) doesnt work.Or atleast i cant make it work.Im doing TweenLite.to( myRedText, 1, { alpha:0, repeat:-1, repeatDelay:1, onComplete:ShowRed}); function ShowRed():void { myRedText.alpha = 1 } and it only does it once. And even if i change the repeat from -1 to 10 it still does it once.
    – GregorII
    Feb 8, 2014 at 14:00
  • exactly what i wanted. 10x
    – GregorII
    Feb 8, 2014 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.