In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

波紋

Get Adobe Flash player
by kohie_yamashima 18 May 2009
    Embed
/**
 * Copyright kohie_yamashima ( http://wonderfl.net/user/kohie_yamashima )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/lsMH
 */

package {
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.utils.setInterval;
	import caurina.transitions.Tweener;

	public class hamonn extends Sprite {
		// 前回のマウスの位置を保存する
		private var prevPos:Point;

		public function hamonn():void {
			prevPos = new Point();

			
			setInterval(update, 300);
		}

		private function update():void {
			// 円の表示位置を決定
			var r:Number = Math.pow(Math.random(), 2) * 50;
			var theta:Number = Math.random() * 2 * Math.PI;

			// 円を描写
			var s:Sprite = new Sprite();
                        s.graphics.lineStyle(1, 0x0066cc);
			s.graphics.drawCircle(0, 0, 5 + Math.random() * 5);
			s.x = mouseX + r * Math.cos(theta);
			s.y = mouseY + r * Math.sin(theta);
			s.scaleX = s.scaleY = 0;
			addChild(s);

			// マウスの移動量を計算
			var curPos:Point = new Point(mouseX, mouseY);
			var d:Number = Point.distance(curPos, prevPos);
			prevPos = curPos;

			// アニメーション
			Tweener.addTween(s, {
				time: 3,
				scaleX: d / 15 + 2,   // マウス移動量が多いほど、
				scaleY: d / 15 + 2,   // 円を大きくする
				alpha: 0.05,
				onComplete: function():void{
					removeChild(s);
				}
			});
		}
	}
}