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 Kay 25 Jun 2009
/**
 * Copyright Kay ( http://wonderfl.net/user/Kay )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/hCzS
 */

package {
	import flash.display.Sprite;
	[SWF(width="465", height="465",frameRate="40",backgroundColor="#ffffff")]
	public class Main extends Sprite {
		public function Main():void {
			var ball:Ball = new Ball();
			addChild(ball);
			Wonderfl.capture_delay( 30 );
		}
	}
}

import flash.display.Sprite;
import flash.events.Event;
class Ball extends Sprite {
	private var vx:Number=0;
	private var vy:Number=0;
	private var circle:Sprite;
	private const FRICTION:Number = 0.95;
	private const SPRING:Number = 0.025;
	private const MASS:Number = 30;
	
	public function Ball():void {
		circle = new Sprite();
		circle.graphics.beginFill(0x6666ff);
		circle.graphics.drawCircle(0,0,10);
		circle.x = mouseX;
		circle.y = mouseY+MASS;
		addChild(circle);
		circle.addEventListener(Event.ENTER_FRAME, xRubber);
	}
	
	private function xRubber(e:Event):void {
		/*
		 * 参考:Aquioux's Mouse stalker 001
		 */
		var dx:Number = mouseX - e.target.x;
		var dy:Number = mouseY - e.target.y;
		vx += dx * SPRING;
		vy += dy * SPRING;
		vx *= FRICTION;
		vy *= FRICTION;
		x += vx;
		y += vy + MASS;
		graphics.clear();
		graphics.lineStyle(0,0x999933);
		graphics.moveTo(e.target.x, e.target.y);
		graphics.lineTo(mouseX, mouseY);
	}
}