Hi all! I need your help
I am trying to make a horizontal xml menu. I load the xml and i get the values and i make the buttons. All ok so far. I attach a movieclip to make the buttons. Inside the movieclip is a dynamic textField where i load the text from the xml.
Now i wonder how can i calculate the space between the buttons so the are spaced evenly cause their width is not fixed.
Here is the code
var navLoad:XML = new XML();
navLoad.load("navigation.xml");
navLoad.ignoreWhite = true;
navLoad.onLoad = function(success:Boolean):Void {
if (success) {
//trace("loaded");
var xmlNode = this.firstChild;
var total = xmlNode.childNodes.length;
var butName:Array = [];
var butTitle:Array = [];
var butLink:Array = [];
var spacing = 100;
for (var i:Number = 0; i<total; i++) {
butName* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
butTitle* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
butLink* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
var button = attachMovie("button", "button"+i, _root.getNextHighestDepth());
_root["button"+i].butText.text = butName*;
_root["button"+i].butText.autoSize = "left";
_root["button"+i]._x = _root["button"+i]._width*i;
_root["button"+i]._y = 30;
_root["button"+i].onRelease = function() {
trace("pressed");
};
}
} else {
trace("error");
}
};