basic_glowEffect

by ushisantoasobu
♥0 | Line 63 | Modified 2010-10-21 11:53:49 | MIT License
play

ActionScript3 source code

/**
 * Copyright ushisantoasobu ( http://wonderfl.net/user/ushisantoasobu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rIGS
 */

package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import caurina.transitions.Tweener;
    import flash.filters.GlowFilter;
    import flash.filters.DropShadowFilter;
    
    [SWF(width=400, height=400, frameRate=30, backgroundColor=0x000000)]    
    
    public class FlashTest extends Sprite {
        public function FlashTest() {
            stage.addEventListener(MouseEvent.MOUSE_MOVE, MOUSEMOVEhandler); 
            //stage.addEventListener(Event.ENTER_FRAME, MOUSEMOVEhandler);            
        }
        
        private function MOUSEMOVEhandler(e:MouseEvent):void{
            //private function MOUSEMOVEhandler(e:Event):void{
            
            var flow:GlowFilter = new GlowFilter(0x66ff00, 1, 30, 30, 10, 3, false, false);
            var flow_2:DropShadowFilter = new DropShadowFilter(0, 90, 0x66ff00, 1, 64, 64, 5, 3, false, false, false);
            
            var ball_size:int = Math.floor(Math.random()*20)+5;
            
            var ball:Sprite = new Sprite();
            ball.graphics.beginFill(0xffffff);
            ball.graphics.drawCircle(0,0,ball_size);
            ball.graphics.endFill();
            
            ball.alpha = 0.0;
            
            ball.filters = [flow_2];
            
            ball.addEventListener(Event.ADDED, aaa);
            
            
            ball.x = mouseX;
            ball.y = mouseY;
            //ball.x = Math.random()*380+10;
            //ball.y = Math.random()*380+10;
                  
            stage.addChild(ball);
            
           }
        
        private function aaa(e:Event):void{
            
            var num_x:int = Math.floor(Math.random()*40)-20;
            var num_y:int = Math.floor(Math.random()*40)-20;
            var num_alpha:Number= Math.random()*0.6 + 0.05;
            
            Tweener.addTween(e.target, {
                time:1,
                x:e.target.x + num_x,
                y:e.target.y + num_y,
                alpha:num_alpha,
                scaleX:4,
                scaleY:4,
                transition:"easeOutCubic",
                onComplete:bbb,
                onCompleteParams:[e.target]
                });
        }
       
       private function bbb(ball:Sprite):void{
           
           var num_x:int = Math.floor(Math.random()*50)-25;
            var num_y:int = Math.floor(Math.random()*50)-25;
           
           Tweener.addTween(ball, {
                time:3,
                x:ball.x + num_x,
                y:ball.y + num_y,
                alpha:0.0,
                scaleX:1,
                scaleY:1,
                transition:"easeInOutCubic",
                onComplete:ccc,
                onCompleteParams:[ball]
                });
       }
        
        private function ccc(ball:Sprite):void{
           stage.removeChild(ball);
       }


    }
}