Here is a growing fractal tree…with pretty strong wind at the end:
vars = {len:200, h:120, max:4, age:80};
function generateBranch(clip, level) {
temp = clip.createEmptyMovieClip("branch"+clip.getNextHighestDepth(), clip.getNextHighestDepth());
(clip == _root) ? temp._x=275 : null;
(clip == _root) ? temp._y=400 : temp._y=(Math.random()*vars.h+(vars.len-vars.h))*-1;
(clip != _root) ? temp._rotation=Math.random()*90-45 : null;
temp.lineStyle(3, 0x000000, 100);
temp.lineTo(0, -200);
temp._xscale = temp._yscale=0;
temp.stats = {l: level, c: 0}
temp.onEnterFrame = function() {
this._xscale = (this._yscale += ((100/this.stats.l)-this._yscale)/5);
(this._yscale/(100/level)>.9 && this.stats.c<=this.stats.l*6+1 && this.stats.l<_root.vars.max) ? this.stats.c++ : null;
(this._yscale/(100/level)>.9 && this.stats.c<=this.stats.l*6+1 && this.stats.l<_root.vars.max) ? generateBranch(this, this.stats.l+1) : null;
if (this._yscale/(100/level)>.99) {
(this.stats.l == _root.vars.max) ? addWind(this) : delete this.onEnterFrame;
}
};
}
generateBranch(_root, 1);
function addWind(clip) {
if (clip.stats.l>_root.vars.max-1) {
clip.stats = {age:0, yv:0, xv:0, rv:0};
clip.onEnterFrame = function() {
this.localToGlobal(p={x:this._x, y:this._y});
(this.stats.age>_root.vars.age) ? this.stats.yv += .7 : this.stats.age++;
(this.stats.age>_root.vars.age) ? this.stats.xv += Math.random() : null;
(p.x>750 || p.x>600) ? addWind(this._parent) : null;
(p.y>600) ? this.removeMovieClip() : this._y += this.stats.yv;
(p.x>750) ? this.removeMovieClip() : this._x += this.stats.xv;
};
}
}
EDIT: bedtime