Есть задача: Создать класс, который реализует дерево определенной глубины с заданным кол-вом разветвлений от каждой ветви.
Сделал, но неправильно работает Array в классе, подскажите как решить проблему!
мой класс выглядит так:

Код:
class cTree {
private var branchName:String;
private var currentDepth:Number;
private var numberOfBranches:Number;
private var childBranches:Array = new Array();
public function cTree(brname:String, cdepth:Number, branchnes:Number)
{
this.branchName = brname;
this.currentDepth = cdepth;
this.numberOfBranches = branchnes;
if(this.currentDepth > 0) {
for(var n = 0; n < this.numberOfBranches; n++)
this.childBranches.push(new cTree(this.branchName + " - " + n,this.currentDepth - 1, this.numberOfBranches));
}
}
public function traceTree():Void
{
trace("depth:" + this.currentDepth + " nodeName:" + this.branchName);
if(this.currentDepth > 0) {
for(var n = 0; n < numberOfBranches; n++)
childBranches[n].traceTree();
}
}
}