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

forked from: forked from: forked from: YAM55 (Yet Another matrix 5*5)

ちゃんと距離を測ることにしたw
じつは計算方法も初めて知ったw
Get Adobe Flash player
by taka_milk 14 May 2009
    Embed
// forked from keiso's forked from: forked from: YAM55 (Yet Another matrix 5*5)
// forked from 2state's forked from: YAM55 (Yet Another matrix 5*5)
// forked from 2state's YAM55 (Yet Another matrix 5*5)
// ちゃんと距離を測ることにしたw
// じつは計算方法も初めて知ったw

package
{
	import flash.display.Sprite;
	import flash.events.Event;
    
	[SWF(backgroundColor="#000000",frameRate="30")]
  
	public class YAM55 extends Sprite
	{
		public static const MAX_X:int = 15;
		public static const MAX_Y:int = 15;
		public static const ITEM_SIZE:int = 25;
		public static const SMALL_SIZE:Number = 0.3;
		public static const BIG_SIZE:Number = 1.2;
		public static const AREA:int = 100;
		
		public var ic:Array = new Array(MAX_X);

		public function YAM55():void{
    			var colourArray:Array = [0xE81000,0xFFCA09,0xFF0232,0x001AE8,0x09FF41,0xffffff*Math.random()];

				for(var x:int = 0; x < MAX_X; x++){
				ic[x] = new Array(MAX_Y);
				for(var y:int = 0; y < MAX_Y; y++){
					ic[x][y] = new Sprite();
					ic[x][y].graphics.beginFill(colourArray[Math.round(Math.random()*5)]);
					ic[x][y].graphics.drawCircle(0,0,ITEM_SIZE/2);
					ic[x][y].graphics.endFill();
					addChild(ic[x][y]);
					ic[x][y].x = (x+1) * ITEM_SIZE;
					ic[x][y].y = (y+1) * ITEM_SIZE;
				}
			}
			addEventListener(Event.ENTER_FRAME,reDraw);
		}
		public function reDraw(e:Event):void{
			var inX:int = stage.mouseX;
			var inY:int = stage.mouseY;
			var s:Number;
			for(var x:int = 0; x < MAX_X; x++){
				for(var y:int = 0; y < MAX_Y; y++){
					s = getScale(x,y,inX,inY,ic[x][y].scaleX);
					ic[x][y].scaleX = s;
					ic[x][y].scaleY = s;
				}
			}
		}
		public function getScale(x:int,y:int,ptX:int,ptY:int,nS:Number):Number{
			var rS:Number = 1.0;
			var sp:Number = pointSpan(
				(x+1)*ITEM_SIZE,
				(y+1)*ITEM_SIZE,
				ptX,ptY);
			var size_s:Number = BIG_SIZE - SMALL_SIZE;
			if(sp < AREA){
				rS = SMALL_SIZE + (size_s * ((AREA - sp) / AREA) );
			}else{
				rS = SMALL_SIZE;
			}
			return nS + (rS - nS) / 15
		}
		public function pointSpan(sx:int, sy:int, ex:int, ey:int):Number{
			var xs:int = ex-sx;
			var ys:int = ey-sy;
			return Math.sqrt(xs*xs+ys*ys);
		}
	}
}