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: フラクタルです。

Get Adobe Flash player
by matyui 18 Jun 2009
/**
 * Copyright matyui ( http://wonderfl.net/user/matyui )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/sIPX
 */

// forked from sake's フラクタルです。
package{
	 
	 import caurina.transitions.Tweener;
	 import flash.display.Sprite;
	 import flash.geom.Point;
	 import flash.display.MovieClip;
	 
	 public class Fractale2 extends Sprite{
		 private var first_length:Number = 200;//初期直径
		 private var num:int = 0;
		 private var mcArr:Array = new Array();
		 private var dtime:Number = 0;
		 
		 public function Fractale2(){
			 var sp1:MovieClip = new MovieClip();
			 mcArr.push(sp1);
			 sp1.graphics.beginFill(0x009999*Math.random() , 0.5);
			 sp1.graphics.drawRect(-first_length / 2, -first_length / 2, first_length, first_length);
			 sp1.graphics.endFill();
			 stage.addChild(sp1);
			 sp1.x = stage.stageWidth / 2;
			 sp1.y = stage.stageHeight / 2;
			 sp1.scaleX = sp1.scaleY = 0;
			 Tweener.addTween(sp1, {scaleX:1, scaleY:1, time:1, delay:1 ,transition:"easeOutQuad", onComplete:repeat_func, onCompleteParams:[sp1.x,sp1.y,first_length / 2,0]});
			 
			 //repeat_func(sp1.x,sp1.y,first_length / 2,0);
		 }
		 
		 public function repeat_func(dx:Number,dy:Number,this_length:Number,unvisible_num:Number){
			 var pointArr:Array = new Array();
			 var pointArr2:Array = new Array();
			 var pointArr3:Array = new Array();
			 var pointArr4:Array = new Array();
			 for(var i:int = 1; i <= 4; i++){
				 var sp:MovieClip = new MovieClip();
				 mcArr.push(sp);
				 sp.graphics.beginFill(0x009999*Math.random() , 0.3);
                 sp.graphics.drawRect(-this_length / 2, -this_length / 2, this_length, this_length);
				 sp.graphics.endFill();
				 stage.addChild(sp);
				 sp.alpha = 1;
				 sp.scaleX = sp.scaleY = 0;
				 if(i == 1){
				 	sp.x = dx - this_length;
					sp.y = dy - this_length;
					pointArr[0] = dx - this_length;
					pointArr[1] = dy - this_length;
					if(unvisible_num == 1){
						sp.visible = false;
					}
				 }else if(i == 2){
				 	sp.x = dx - this_length;
					sp.y = dy + this_length;
					pointArr2[0] = dx - this_length;
					pointArr2[1] = dy + this_length;
					if(unvisible_num == 2){
						sp.visible = false;
					}
				 }else if(i == 3){
				 	sp.x = dx + this_length;
					sp.y = dy + this_length;
					pointArr3[0] = dx + this_length;
					pointArr3[1] = dy + this_length;
					if(unvisible_num == 3){
						sp.visible = false;
					}
				 }else if(i == 4){
				 	sp.x = dx + this_length;
					sp.y = dy - this_length;
					pointArr4[0] = dx + this_length;
					pointArr4[1] = dy - this_length;
					if(unvisible_num == 4){
						sp.visible = false;
					}
				 }
				 trace(first_length);
				 if(sp.y > stage.stageHeight / 2 - first_length / 2 && sp.y < stage.stageHeight / 2 + first_length / 2){
					 if(sp.x > stage.stageWidth / 2 - first_length / 2 && sp.x < stage.stageWidth / 2 + first_length / 2){
					 	sp.visible = false;
					 }
					 
				 }
				 dtime += 0.02;
				 Tweener.addTween(sp, {scaleX:1, scaleY:1, time:1, delay:dtime, transition:"easeOutSine"});
				 
			 }
			 var next_length:Number = this_length / 2;
			 num++;
			 if(next_length >= 20){
				 repeat_func(pointArr[0],pointArr[1],next_length,3);
				 repeat_func(pointArr2[0],pointArr2[1],next_length,4);
				 repeat_func(pointArr3[0],pointArr3[1],next_length,1);
				 repeat_func(pointArr4[0],pointArr4[1],next_length,2);
				 
			 }
		 }
	}
}