"for" not working, might be the undefined

I guys, i an new here in kirupa.

I have this problem with my script.

The duplicate “for” is not starting, it should duplicate the button, but for some reason the first loop is undefined. Maybe you guys can help me out. I am pretty new to all this…


xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
link = [];
total = xmlNode.childNodes.length;
totalPromos = total;
for (i=0; i<total; i++) {
trace(i);
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
link* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
}
newpos = previous_btn._x-20;
for (loop=totalPromos; loop>=1; loop--) {
trace(newButt);
newButt = b.duplicateMovieClip("b"+loop, loop);
newButt.label = loop;
newButt._x = newpos-newButt._width;
newButt._y = Math.round(Stage.height-newButt._height+5);
newpos = newButt._x;
}
firstImage();
} else {
content = "where is the xml?!";
}
}