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 sake's フラクタルです。
/*
	フラクタル。
	再帰の復習です。
*/

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

	[SWF(width="465", height="465", backgroundColor="0xFFFFFF", frameRate="40")]

	public class Fractale extends Sprite
	{
		private var centerP:Point=new Point(465 / 2, 465 / 2);
		private var square_len:int=120;
		private var min_len:int=5;

		private var center:int=0;
		private var lt:int=4;
		private var lb:int=2;
		private var rt:int=3;
		private var rb:int=1;

		private var dtime:Number=0;

		public function Fractale()
		{
			star(centerP.x, centerP.y, square_len, center);
		}

		public function star(xx:Number, yy:Number, r:int, n:int):void
		{
			if (r > min_len)
			{

				dtime+=0.02;

				if (n == center)
				{
					star(xx + r, yy - r, r / 2, rb);
					star(xx - r, yy - r, r / 2, lb);
					star(xx + r, yy + r, r / 2, rt);
					star(xx - r, yy + r, r / 2, lt);

					var sp:Sprite=new Sprite;
					sp.graphics.beginFill(0xffffff * Math.random(), 0.5);
					sp.graphics.drawRect(-r, -r, 2 * r, 2 * r);
					sp.graphics.endFill();
					addChild(sp);
					sp.alpha=1;
					sp.x=xx;
					sp.y=yy;
					sp.scaleX=0;
					sp.scaleY=0;
					Tweener.addTween(sp, {scaleX:1, scaleY:1, time:3, delay:dtime, transition:"easeOutBounce"});
				}
				else if (n == rb)
				{
					star(xx + r, yy - r, r / 2, rb);
					star(xx - r, yy - r, r / 2, lb);
					star(xx + r, yy + r, r / 2, rt);

					var sp:Sprite=new Sprite;
					sp.graphics.beginFill(0xffffff * Math.random(), 0.5);
					sp.graphics.drawRect(-r, -r, 2 * r, 2 * r);
					sp.graphics.endFill();
					addChild(sp);
					sp.alpha=1;
					sp.x=xx;
					sp.y=yy;
					sp.scaleX=0;
					sp.scaleY=0;
					Tweener.addTween(sp, {scaleX:1, scaleY:1, time:3, delay:dtime, transition:"easeOutBounce"});
				}
				else if (n == lb)
				{
					star(xx + r, yy - r, r / 2, rb);
					star(xx - r, yy - r, r / 2, lb);
					star(xx - r, yy + r, r / 2, lt);

					var sp:Sprite=new Sprite;
					sp.graphics.beginFill(0xffffff * Math.random(), 0.5);
					sp.graphics.drawRect(-r, -r, 2 * r, 2 * r);
					sp.graphics.endFill();
					addChild(sp);
					sp.alpha=1;
					sp.x=xx;
					sp.y=yy;
					sp.scaleX=0;
					sp.scaleY=0;
					Tweener.addTween(sp, {scaleX:1, scaleY:1, time:3, delay:dtime, transition:"easeOutBounce"});
				}
				else if (n == rt)
				{
					star(xx + r, yy - r, r / 2, rb);
					star(xx + r, yy + r, r / 2, rt);
					star(xx - r, yy + r, r / 2, lt);

					var sp:Sprite=new Sprite;
					sp.graphics.beginFill(0xffffff * Math.random(), 0.5);
					sp.graphics.drawRect(-r, -r, 2 * r, 2 * r);
					sp.graphics.endFill();
					addChild(sp);
					sp.alpha=1;
					sp.x=xx;
					sp.y=yy;
					sp.scaleX=0;
					sp.scaleY=0;
					Tweener.addTween(sp, {scaleX:1, scaleY:1, time:3, delay:dtime, transition:"easeOutBounce"});
				}
				else if (n == lt)
				{
					star(xx - r, yy - r, r / 2, lb);
					star(xx + r, yy + r, r / 2, rt);
					star(xx - r, yy + r, r / 2, lt);

					var sp:Sprite=new Sprite;
					sp.graphics.beginFill(0xffffff * Math.random(), 0.5);
					sp.graphics.drawRect(-r, -r, 2 * r, 2 * r);
					sp.graphics.endFill();
					addChild(sp);
					sp.alpha=1;
					sp.x=xx;
					sp.y=yy;
					sp.scaleX=0;
					sp.scaleY=0;
					Tweener.addTween(sp, {scaleX:1, scaleY:1, time:3, delay:dtime, transition:"easeOutBounce"});
				}
			}
		}
	}
}