I'm basically trying to create a tree diagram. I've created the 1st level and I wanted to put it into an array so the next level would be able to get the properties from the previous level/array.
But now it seems like I cannot push the circles with its own unique"name" into circlesNewArray. what's the problem here?
I'm still not sure if the way i construct my code for dynamic intance/data/mc with max 2 separation is correct or not, as I think it involves 2 to 3 array to keep it gouped among same level when data loads, and regroup again when doing level separation.
If you have any better idea it would be greatly appreciated too. thanx!
private function dataLevel():void {
rootLevel=new Array();
rootLevel.push(20,200);
newArray=new Array();
var no1:Number=1;
var no2:Number=2;
if (rootLevel is Array==true) {
createBranch(rootLevel);
for (var j:Number=0; j<rootLevel.length; j++) {
newArray[j]=new Array();
newArray[j].push(j);
createBranch(newArray[j]);
}
}
}
//-------------------------------------------------------------------
private function createBranch(runningObj:Object):void {
circlesNewArray = new Array();
var i2=i-1;
for (var i:Number=0; i<runningObj.length; i++) {
circles = new MovieClip();
var empty=null;
circles.graphics.beginFill(0xFF2222);
circles.graphics.drawCircle(empty,empty,10);
circles.graphics.endFill();
//Passing 2 cirls in an Array
circlesNewArray[i]=new Array();
circles.name="circles"+i;
circlesNewArray[i].push(circles[i]);
if (runningObj==rootLevel) {
circles.x=trunks.x - (Math.floor(Math.random()*100)-50);
circles.y=trunks.y - (Math.floor(Math.random()*100));
} else if (runningObj!=rootLevel) {
circles.x=circlesNewArray[i2]-(Math.floor(Math.random()*100)-50);
circles.y=circlesNewArray[i2]-(Math.floor(Math.random()*100));
}
//trace(circles.x, circles.y);
circles.buttonMode=true;
circles.addEventListener(MouseEvent.CLICK, clickTarget);
addChild(circles);
}
}