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

TreeCurve

木に見えるフラクタル
Get Adobe Flash player
by ton 13 Jan 2009
//木に見えるフラクタル
package {
	import flash.display.Sprite;
	import flash.events.*;
	import flash.geom.Point;
	[SWF(backgroundColor=0x000000)]
	public class TreeCurve extends Sprite {
		private var list:Array = new Array();
		private const SIZE:int = 465;
		private const RAD:Number = Math.PI/8;
		private const a:Number = 0.75;
		function TreeCurve() {
			addLine(new Line(new Point(SIZE/2, SIZE), new Point(SIZE/2, SIZE*4/5)));
			stage.addEventListener(Event.ENTER_FRAME,onEnterFrameHandler);
		}
		private function onEnterFrameHandler(event:Event):void {
			var line:Line=list[0];
			list.splice(0, 1);
			addLine(new Line(line.endP, new Point(line.endP.x + line.distance * a * Math.cos(line.angle + RAD), line.endP.y + line.distance * a * Math.sin(line.angle+RAD))));
			addLine(new Line(line.endP, new Point(line.endP.x + line.distance * a * Math.cos(line.angle - RAD), line.endP.y + line.distance * a * Math.sin(line.angle - RAD))));
		}
		private function addLine(line:Line):void {
			list.push(line);
			addChild(line);
		}
	}
}
	
import flash.display.Sprite;
import flash.geom.Point;
class Line extends Sprite {
	public var startP:Point;
	public var endP:Point;
	public var distance:Number;
	public var angle:Number;
	function Line(startP:Point, endP:Point) {
		this.startP = startP;
		this.endP = endP;
		angle = Math.atan2(endP.y-startP.y, endP.x-startP.x);
		distance = Point.distance(startP, endP);
		graphics.lineStyle(0,0xffffff);
		graphics.moveTo(startP.x, startP.y);
		graphics.lineTo(endP.x, endP.y);
		graphics.endFill();
	}
}