Question

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 ????
    }
Was it helpful?

Solution

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...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top