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

spring02

研究室内勉強会: バネその2
Get Adobe Flash player
by sakef 01 Jun 2010
    Embed
/**
 * Copyright sakef ( http://wonderfl.net/user/sakef )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/yPgC
 */

/*
	研究室内勉強会: バネその2
*/
package
{
	import flash.display.Sprite;
	import flash.events.Event;
	
	[SWF(width="465", height="465", backgroundColor="0x000000", frameRate="30")]
	public class bane02 extends Sprite
	{
		private var ary:Array;
		
		public function bane02()
		{
			ary=[];
			
			var ball:BaneBall;
			for(var i:int=0; i < 10; i++)
			{
				ball=new BaneBall();
				addChild(ball);
				ary[i]=ball;
			}
			
			addEventListener(Event.ENTER_FRAME, onFrame);
		}
		
		private function onFrame(e:Event):void
		{
			for(var i:int=0; i < 10; i++) (ary[i]as BaneBall).update();
		}
	}
}


import flash.display.Shape;

class BaneBall extends Shape
{
	private var vx:Number;
	private var vy:Number;
	private var k:Number;
	private var f:Number
	
	public function BaneBall()
	{
		k=0.04 + 0.02 * Math.random();
		f=0.8 + 0.15 * Math.random();
		vx=vy=0;
		
		graphics.beginFill(0x00ffff * Math.random(), 1);
		graphics.drawCircle(0, 0, 5);
		graphics.endFill();
	}
	
	public function update():void
	{
		vx+=(stage.mouseX - x) * k;
		vy+=(stage.mouseY - y) * k;
		
		x+=vx;
		y+=vy;
		
		vx*=f;
		vy*=f;
	}
}