Hi all,
I have this loop code that counts up the XML nodes and creates menu items for each node, that was taken from a tutorial. How can I have it so after 10 nodes it creates a new column setting them side by side? Moving them say 100px on the x axis? Here is the 1st part of the code that works:
Code:
Code:
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function (success:Boolean) {
var properties:Array = xml.firstChild.childNodes;
for(var i:Number = 0; i<properties.length; i++)
{
var row:MovieClip = attachMovie("row", "row" + i, getNextHighestDepth(), {xml_data:properties[i]})
row._y = i * (row._height + 2);
}
}
xml.load("Properties-Master.xml");
The code listed above checks the XML file and creates buttons for every node. Here is the second code creating the columns, my friend helped with this but he didn't tell me where to put it with my previous code. Little help anybody?
Code:
Code:
// its better practice to declare all of your variables first and reassigning them instead of redeclaring them over and over.
var maxRows:Number = 10;
var numColumns:Number = 0;
var counter:Number = 1;
var max:Number = properties.length;
var columnWidth:Number = 100;
var rowHeight:Number = 30;
var xPos:Number;
var yPos:Number;
for( var i:Number = 0; i < max; i++){
xPos = columnWidth * numColumns;
yPos = counter * rowHeight;
myRow._x = xPos;
myRow._y = yPos;
if(counter == maxRows){
counter = 1;
numColumns++;
} else {
counter++
}
Hope this makes sense.
Thanks!