PDA

View Full Version : XML - trouble assigning URL


spoakes2000
08-09-2006, 04:28 PM
I'm trying to get a unique URL assigned to each button, but they all end up with either the same URL or "undefined". What am I doing wrong? Any suggestions on how to set up the button mc would be appreciated too.

menuXml = new XML();
menuXml.onLoad = headerLoad;
menuXml.load("myData.xml");
menuXml.ignoreWhite = true;

function headerLoad(success) {
if (success == true) {
buttonNode = menuXml.firstChild.firstChild;
currentButtonNode = buttonNode;
// total number of buttons
buttonItems = menuXml.firstChild.childNodes;
maxButtons = buttonItems.length;
// call function
buttonLoop(currentButtonNode);
}
}

function buttonLoop(currentButtonNode) {
for( i = 0; i<maxButtons; i++){

buttonText = currentButtonNode.attributes.lableText;
buttonURL = currentButtonNode.attributes.link;

var bt = this.attachMovie("mc", "button" + i, i);

menuColor = new Color(bt.colorBk);
menuColor.setRGB(currentButtonNode.attributes.btCo lor);

bt._y = (i+460)+ (i * 35);
bt._x = i + 165;

bt.label_txt.text = buttonText;
bt.button_btn.onRelease = function() {
getURL(buttonURL, "_self")
}

currentButtonNode = currentButtonNode.nextSibling;}

};

jharmon
08-10-2006, 03:47 PM
i think it is a simple problem with the way your loop is set up... i made a few changes to the loop. hope this works...


menuXml = new XML();
menuXml.onLoad = headerLoad;
menuXml.load("myData.xml");
menuXml.ignoreWhite = true;

function headerLoad(success) {
if (success == true) {

buttonItems = menuXml.firstChild.childNodes;
maxButtons = buttonItems.length;

for( i = 0; i<maxButtons; i++){

buttonNode = menuXml.firstChild.childNodes[i];
buttonText = buttonNode.attributes.lableText;
buttonURL = buttonNode.attributes.link;

var bt = this.attachMovie("mc", "button" + i, i);

menuColor = new Color(bt.colorBk);
menuColor.setRGB(buttonNode.attributes.btColor);

bt._y = (i+460)+ (i * 35);
bt._x = i + 165;

bt.label_txt.text = buttonText;
bt.button_btn.onRelease = function() {
getURL(buttonURL, "_self")
}
}
}
}

spoakes2000
08-14-2006, 08:22 PM
Hi-
The weird thing is - now I'm not getting any buttons on stage at all. Could it be how I'm setting up my "mc" button? Not sure. Thanks for the help!