as3.0 TweenLite TextField颜色渐变

package src

{

    import com.bit101.components.Label;

    import com.bit101.components.Style;

    import flash.text.TextField;

    import flash.text.TextFormat;

    

    import flash.display.MovieClip;

    import flash.display.Sprite;

    import flash.events.MouseEvent;

    

    import com.greensock.TweenLite;

    import com.greensock.plugins.TintPlugin;

    import com.greensock.plugins.TweenPlugin;

    import com.greensock.plugins.GlowFilterPlugin;

    import com.greensock.plugins.ColorMatrixFilterPlugin;

    

    public class TweenLitePlugins extends MovieClip

    {

        public var _text:TextField;

        private var _image:MovieClip;

       

        public function TweenLitePlugins()

        {

            _image = new Ladeng();

            _image.x = stage.stageWidth / 2 - _image.width / 2;

            _image.y = 200;

            addChild(_image);

           

            stage.addEventListener(MouseEvent.MOUSE_DOWN, onStageMouseDown);

            createText();

            activatePlugins();

            setUI();

        }

       

        private function createText():void

        {

            var tf:TextFormat = new TextFormat("Impact", 40, 0);

            _text = new TextField();

            _text.text = "TintEffect with TweenLite";

            _text.setTextFormat(tf);

            _text.width = _text.textWidth+10;

            _text.x = stage.stageWidth / 2 - _text.width / 2;

            _text.y = stage.stageHeight / 2 - _text.height / 2;

            addChild(_text);

        }

       

        private function activatePlugins():void

        {

            TweenPlugin.activate([TintPlugin,GlowFilterPlugin,ColorMatrixFilterPlugin]);

        }

        private function setUI():void

        {

            Style.embedFonts = false;

            Style.fontSize = 12;

           

            var label:Label = new Label(this, 10, 30, "点击舞台,TweenLite会将文本内容缓动至一个随机的颜色。n同时将图像缓动至相同的随机颜色。");

            label.setSize(450,300);

        }

       

        private function onStageMouseDown(me:MouseEvent):void

        {

            var color:Number = Math.random() * 256 * 256 * 256;

            TweenLite.to(_text, 1, { tint:color, glowFilter: { color:0xff0000, alpha:1, blurX:50, blurY:60 }} );

            TweenLite.to(_image, 1, { colorMatrixFilter: { colorize:color, amout:1 }});

        }

       

    }



}

使用TweenPlugin的静态activate方法激活相应的插件

下面是TweenLite为我们提供的插件列表:

你可能感兴趣的:(textfield)