Section 1
//Branch (com.rutgervd.TreeSeed.V2.Branch)
package com.rutgervd.TreeSeed.V2 {
public class Branch extends TreeElement {
public var angleIncrease:Number;// = 8
public var outlineColor:Number;// = 0xDFDFDF
public var outlineThickness:Number;// = 2
public var drawOutline:Boolean;// = true
public var growSize:Number;// = 5.5
public function Branch(){
drawOutline = true;
outlineThickness = 2;
outlineColor = 0xDFDFDF;
growSize = 5.5;
angleIncrease = 8;
super();
addColor(0);
setColor();
}
public function growStep():void{
var _local1:*;
var _local2:*;
var _local3:Number;
var _local4:*;
var _local5:*;
var _local6:*;
curSize = (curSize / 1.033);
graphics.clear();
if (curSize < 1.5){
tree.removeDaughter(this);
return;
};
if (curSize < 15){
growFoliage();
};
_local1 = curX;
_local2 = curY;
curAngle = (curAngle + ((Math.random() * angleIncrease) - (angleIncrease / 2)));
_local3 = getRadians(curAngle);
_local4 = (growSize * Math.sin(_local3));
_local5 = (growSize * Math.cos(_local3));
curX = (curX + _local4);
curY = (curY + _local5);
if (drawOutline){
if (curSize > 1.5525){
graphics.lineStyle((curSize + outlineThickness), outlineColor);
graphics.moveTo((_local1 + (2 * _local4)), (_local2 + (2 * _local5)));
graphics.lineTo(curX, curY);
};
};
graphics.lineStyle(curSize, color);
graphics.moveTo(_local1, _local2);
graphics.lineTo(curX, curY);
_local6 = Math.floor((Math.random() * curSize));
if (_local6 < (curSize / 42)){
tree.addElement("branch", curX, curY, (curAngle - ((Math.random() * 90) - 45)), (curSize - (Math.random() * 4)));
};
}
public function growFoliage(){
if (Math.floor((Math.random() * 4)) == 1){
tree.addElement("leaf", ((curX + (Math.random() * 20)) - 10), ((curY + (Math.random() * 20)) - 15), 0, (Math.random() * 10));
};
}
}
}//package com.rutgervd.TreeSeed.V2
Section 2
//Leaf (com.rutgervd.TreeSeed.V2.Leaf)
package com.rutgervd.TreeSeed.V2 {
public class Leaf extends TreeElement {
public var delay:Number;// = 0
public function Leaf(){
delay = 0;
super();
addColor(16764159);
addColor(16755455);
addColor(0xFFFFFF);
addColor(16772863);
setColor();
delay = 4;
}
override public function setValues(_arg1, _arg2, _arg3, _arg4){
super.setValues(_arg1, _arg2, _arg3, _arg4);
curSize = 0;
}
public function growStep():void{
if (delay > 0){
delay--;
return;
};
if (removeNext){
tree.removeDaughter(this);
return;
};
curSize = (curSize + 50);
if (curSize > startSize){
curSize = startSize;
removeNext = true;
};
graphics.beginFill(color, ((Math.random() * 10) / 10));
graphics.drawCircle(curX, curY, curSize);
}
}
}//package com.rutgervd.TreeSeed.V2
Section 3
//TreeElement (com.rutgervd.TreeSeed.V2.TreeElement)
package com.rutgervd.TreeSeed.V2 {
import flash.display.*;
public class TreeElement extends Sprite {
public var curY:Number;
public var startX:Number;
public var startY:Number;
public var curX:Number;
public var color:Number;
public var curSize:Number;
public var colors:Array;
public var curAngle:Number;
public var startSize:Number;
public var startAngle:Number;
public var removeNext:Boolean;// = false
public var tree:TreeSeed;
public var mother:TreeElement;
public function TreeElement(){
removeNext = false;
super();
colors = new Array();
}
public function setValues(_arg1, _arg2, _arg3, _arg4){
curX = (startX = _arg1);
curY = (startY = _arg2);
curAngle = (startAngle = _arg3);
curSize = (startSize = _arg4);
}
public function getRadians(_arg1:Number):Number{
return (((_arg1 * Math.PI) / 180));
}
public function addColor(_arg1){
colors.push(_arg1);
}
public function setColor(_arg1:Number=0){
if (_arg1 == 0){
_arg1 = Math.round((Math.random() * (colors.length - 1)));
};
color = colors[_arg1];
}
}
}//package com.rutgervd.TreeSeed.V2
Section 4
//TreeSeed (com.rutgervd.TreeSeed.V2.TreeSeed)
package com.rutgervd.TreeSeed.V2 {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.text.*;
import flash.geom.*;
public class TreeSeed extends Sprite {
private var btn:redrawBtn;
private var daughters:Array;
private var bmpData:BitmapData;
private var children:Sprite;
public function TreeSeed(){
buildTree();
}
public function reDraw(_arg1:MouseEvent){
removeChild(btn);
bmpData.fillRect(new Rectangle(0, 0, 1200, 700), 0);
addElement("branch", 600, 700, 180);
addEventListener(Event.ENTER_FRAME, growTree);
}
public function addElement(_arg1:String, _arg2:int, _arg3:int, _arg4:Number=90, _arg5:Number=100):void{
var _local6:TreeElement;
if (_arg1 == "branch"){
_local6 = TreeElement(new Branch());
} else {
if (_arg1 == "leaf"){
_local6 = TreeElement(new Leaf());
};
};
_local6.setValues(_arg2, _arg3, _arg4, _arg5);
_local6.tree = this;
addDaughter(_local6);
}
public function buildTree(){
var _local1:Bitmap;
bmpData = new BitmapData(1200, 700, true, 0);
_local1 = new Bitmap(bmpData);
addChild(_local1);
children = new Sprite();
addChild(children);
daughters = new Array();
addElement("branch", 600, 700, 180);
addEventListener("enterFrame", growTree);
}
public function reset(){
removeEventListener(Event.ENTER_FRAME, growTree);
btn = new redrawBtn();
btn.x = 205;
btn.y = 680;
btn.addEventListener(MouseEvent.CLICK, reDraw);
addChild(btn);
}
private function growTree(_arg1:Event){
var _local2:Number;
_local2 = 0;
while (_local2 < daughters.length) {
daughters[_local2].growStep();
_local2++;
};
bmpData.draw(this);
if (daughters.length == 0){
reset();
};
}
public function removeDaughter(_arg1:TreeElement):void{
daughters.splice(daughters.indexOf(_arg1), 1);
children.removeChild(_arg1);
_arg1 = null;
}
public function addDaughter(_arg1){
daughters.push(_arg1);
children.addChild(_arg1);
}
}
}//package com.rutgervd.TreeSeed.V2
Section 5
//lol_1 (main_fla.lol_1)
package main_fla {
import flash.display.*;
public dynamic class lol_1 extends MovieClip {
public function lol_1(){
addFrameScript(0, frame1);
}
function frame1(){
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.BOTTOM;
}
}
}//package main_fla
Section 6
//redrawBtn (redrawBtn)
package {
import flash.display.*;
public dynamic class redrawBtn extends SimpleButton {
}
}//package