zoukankan      html  css  js  c++  java
  • 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为我们提供的插件列表:

  • 相关阅读:
    记一份电网信息化建设企业信息分析平台规划
    2018年个人心灵历程记录
    OGG For Bigdata To Kafka同步问题处理
    Vue.js有赞商城(思路以及总结整理)
    汉诺塔-递归算法
    git合并分支
    js实现页面消息滚动效果
    chrome实现网页高清截屏(F12、shift+ctrl+p、capture)
    JS计算时间差
    Socket.io详解
  • 原文地址:https://www.cnblogs.com/lxiang/p/2851876.html
Copyright © 2011-2022 走看看