flash on 2009-9-19

by hacker_9p8x8mco
♥0 | Line 32 | Modified 2009-09-19 18:42:19 | MIT License
play

ActionScript3 source code

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

package{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.utils.Timer;
	public class Anime1 extends Sprite{
		public function Anime1():void{
			stage.addEventListener("click",clickHandler);
		}
		public function clickHandler(event:MouseEvent):void{
			var s:Sprite = new Sprite();
			s.graphics.beginFill(Math.random() * 0x100000);
			s.graphics.drawCircle(0,0,10);
			s.graphics.endFill();
			addChild(s);
			s.x = event.stageX;
			s.y = event.stageY;
			var timer:Timer = new Timer(50,20);
			timer.start();
			s.scaleX = s.scaleY = 0;
			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;
			});
			timer.addEventListener("timerComplete",function(event:Event):void{
				removeChild(s);
			});
		}
	}
}