Forked from: Chang.Shu.Huai's WhycatTree2 forked from: WhycatTree1 diff:23 WhycatTree2 in Green Random Chang.Shu.Hu.. forked:1favorite:0lines:63license : All rights reserved modified : 2012-04-14 11:51:29 Embed Tweet // forked from Chang.Shu.Huai's WhycatTree2 forked from: WhycatTree1 // forked from Chang.Shu.Huai's WhycatTree1 Finish // forked from Chang.Shu.Huai's WhycatTree1 package { import flash.events.MouseEvent; import flash.display.Sprite; import flash.events.Event; public class FlashTest extends Sprite { private var Max_Level:Number=10; private var arr2:Array; private var level:Number=0; private var arr:Array; public function action(e:Event):void{ if(level<=Max_Level){ arr2=new Array(); level++; for each (var DL:DrawLine in arr){ DL.Draw(); addChild(DL); arr2.push(DL.Copy(true)); arr2.push(DL.Copy(false)); } arr=arr2; } } public function click( e:MouseEvent):void{ removeChildren(); level=0; arr=new Array(); arr.push(new DrawLine(250,500,-Math.PI/2,150)); } public function FlashTest() { arr=new Array(); arr.push(new DrawLine(250,500,-Math.PI/2,150)); addEventListener( Event.ENTER_FRAME, action ); stage.addEventListener( MouseEvent.MOUSE_DOWN, click); // write as3 code here.. } } } import flash.display.Shape; const BILI:Number=0.75; class DrawLine extends Shape{ public var xx:Number; public var yy:Number; public var ang:Number; public var len:Number; private var delta_ang:Number=Math.PI/4; private var bili:Number=Math.random()*0.4+0.4; //private var bili:Number=0.5; public function DrawLine(X:Number,Y:Number,A:Number,L:Number):void{ this.x=0; this.y=0; xx=X; yy=Y ang=A; len=L; } public function Draw():void{ graphics.lineStyle(2,0x666622); graphics.moveTo(xx,yy); graphics.lineTo(xx+len*Math.cos(ang),yy+len*Math.sin(ang)); } public function Copy(positive:Boolean):DrawLine{ if(positive==true)return new DrawLine(xx+len*Math.cos(ang),yy+len*Math.sin(ang),ang+delta_ang,len*bili) else return new DrawLine(xx+len*Math.cos(ang),yy+len*Math.sin(ang),ang-delta_ang,len*(1-bili+0.2)) } } Code Fullscreen Preview Fullscreen Math.cos addEventListener Math.sin push Math.PI Shape Event.ENTER_FRAME Event Array Boolean Math.random Number sort new page view favorite forked pv79 WhycatTree2 in Green Random f.. Chang.Shu.Huai forked:0 favorite:0lines:55 (diff:4)