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

moyou

Get Adobe Flash player
by miyaoka 19 Dec 2008
/**
 * Copyright miyaoka ( http://wonderfl.net/user/miyaoka )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/5De8
 */

package 
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	public class Main extends Sprite 
	{
		private var col:uint = 20;
		private var row:uint = 10;
		private var bgColors:Array = [0xFFFFFF, 0x000000];
		private var bgColorIdx:uint = 0;
		
		public function Main():void 
		{
			setShapes();
			stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseClickHandler);
		}
		private function mouseClickHandler(evt:MouseEvent):void 
		{
			setShapes();
		}	
		private function setShapes():void 
		{
			graphics.clear();
			graphics.beginFill(bgColors[bgColorIdx]);
			graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
			graphics.endFill();
			bgColorIdx = ++bgColorIdx % bgColors.length;
			
			while(0 < numChildren) removeChildAt(0);
			
			var c:uint;
			var r:uint;
			var rot:uint;

			var size:Number = 25;
			var center:Number = (Math.random() * 2 - 1) * size * 0.5;
			
			for (rot = 0; rot < 4; rot++)
			{
				var xDif:Number = ((rot == 0 || rot == 3) ? 1: -1);
				var yDif:Number =  ((rot == 0 || rot == 1) ? 1: -1);
				for (c = 0; c < col; c++)
				{
					for (r = 0; r < row; r++)
					{
						var sp:Shape = new Shape(this, size, size, center,center);
						sp.rotation = 90 * rot;
						sp.x = size * c + size * xDif;
						sp.y = size * 2 * (r + c%2*0.5) + size * yDif;
					}
				}
			}
		}
	}	
}


import flash.display.DisplayObjectContainer;
import flash.display.Sprite
import flash.events.MouseEvent;
import flash.geom.Point;

class Shape
extends Sprite
{
	public function Shape(parent_:DisplayObjectContainer, width_:Number = 25, height_:Number=25, centerX:Number = 0, centerY:Number = 0):void 
	{
		parent_.addChild(this);
		stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler,false,0,true);

        graphics.beginFill(Math.random() * 0xFFFFFF);
		graphics.moveTo(width_ / 2 - centerX, 0 - centerY);
		graphics.curveTo(width_ - centerX, 0 - centerY, width_/2 - centerX, height_/2 - centerY);
		graphics.curveTo(0 - centerX, height_ - centerY, 0 - centerX, height_/2 - centerY);
		graphics.curveTo(0 - centerX, 0 - centerY, width_/2 - centerX, 0 - centerY);	
        graphics.endFill();
	}
	private function mouseMoveHandler(evt:MouseEvent):void 
	{
		 scaleX = scaleY = Math.min(2, Math.sqrt(25 / Point.distance(new Point(), new Point(mouseX, mouseY))) * 2);
	}
}