zoukankan      html  css  js  c++  java
  • 加濾鏡效果GlowTween

    /**
     * 
     * new GlowTween(xxxx, 0xFFFF00);
     * new GlowTween(xxxx, 0x00FFFF);
     * GlowTween
     */
    
    package com.riaidea.tween
    {    
        import flash.display.InteractiveObject;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.filters.GlowFilter;
        
        public class GlowTween
        {
            private var _target:InteractiveObject;
            private var _color:uint;
            private var _toggle:Boolean;
            private var _blur:Number;
            
            public function GlowTween(target:InteractiveObject, color:uint = 0xFFFFFF)
            {
                _target = target;
                _color = color;
                _toggle = true;
                _blur = 2;
                target.addEventListener(MouseEvent.ROLL_OVER, startGlowHandler);
                target.addEventListener(MouseEvent.ROLL_OUT, stopGlowHandler);    
            }
            
            public function remove():void
            {
                _target.removeEventListener(MouseEvent.ROLL_OVER, startGlowHandler);
                _target.removeEventListener(MouseEvent.ROLL_OUT, stopGlowHandler);    
                _target.removeEventListener(Event.ENTER_FRAME, blinkHandler);
                _target.filters = null;
                _target = null;
            }        
            
            private function startGlowHandler(evt:MouseEvent):void
            {
                _target.addEventListener(Event.ENTER_FRAME, blinkHandler, false, 0, true);                
            }
            
            private function stopGlowHandler(evt:MouseEvent):void
            {
                _target.removeEventListener(Event.ENTER_FRAME, blinkHandler);            
                _target.filters = null;
            }
            
            private function blinkHandler(evt:Event):void
            {
                if (_blur >= 20) _toggle = false;
                else if (_blur <= 2) _toggle = true;
                _toggle ? _blur++ : _blur--;            
                var glow:GlowFilter = new GlowFilter(_color, 1, _blur, _blur, 2, 2);
                _target.filters = [glow];    
            }
        }    
    }
  • 相关阅读:
    [MySQL] 怎样使用Mysqlcheck来检查和修复, 优化表
    MySQL 5.6 & 5.7最优配置文件模板
    mysql5.6配置详解
    mysql 复制数据库
    mysql-binlog日志恢复数据库
    Memory Analyzer Tool定位Java heap space内存泄漏
    MySQL Flashback 闪回功能详解
    DisJSet:食物链(POJ 1182)
    BFS:Meteor Shower(POJ 3669)
    DFS:Curling 2.0(POJ 3009)
  • 原文地址:https://www.cnblogs.com/602147629/p/3843021.html
Copyright © 2011-2022 走看看