码迷,mamicode.com
首页 > 其他好文 > 详细

加濾鏡效果GlowTween

时间:2014-07-14 18:54:55      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   art   io   cti   

/**
 * 
 * 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];    
        }
    }    
}

 

加濾鏡效果GlowTween,布布扣,bubuko.com

加濾鏡效果GlowTween

标签:style   blog   color   art   io   cti   

原文地址:http://www.cnblogs.com/602147629/p/3843021.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!