flash on 2010-12-13

by asobuno2010
♥0 | Line 32 | Modified 2010-12-13 18:12:58 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.utils.Timer;
    
    public class Anime1 extends Sprite {
        
        public function Anime1():void {
            stage.addEventListener("click", clickHandler);
        }
        private function clickHandler(event:MouseEvent):void {
        var s:Sprite = new Sprite ();
        s.graphics.beginFill(Math.random() * 0x1000000);
        s.graphics.drawCircle(20,10,10);
        s.graphics.endFill();
        addChild(s);
        
        s.x = event.stageX;
        s.y = event.stageY;
        
        var timer:Timer = new Timer (50,20);
        timer.start();
        timer.addEventListener("timer", function(event:Event):void {
                               var ratio:Number = timer.currentCount / timer.repeatCount;
                               s.alpha = 1-ratio;
                               s.scaleX = 5*ratio;
                               s.scaleY = 5*ratio;
                               s.rotation = 360*ratio;
                               });
        timer.addEventListener("timerComplete", function(event:Event):void {
                               removeChild(s);
                               });
        }
    }
}

Forked