Tracing array from a xml doesn`t work
I`m trying to trace the pics[1] but I just get undefined when it`s out of the doMenu function. Do you know how to fix it?
var xmlDoc:XML = new XML();
System.useCodepage = true;
xmlDoc.ignoreWhite = true;
xmlDoc.onLoad = function(ok:Boolean) {
if (ok) {
doMenu(this);
} else {
trace("XML did not load");
}
};
xmlDoc.load("images.xml");
function doMenu(xml:XML) {
var num:Number = xml.firstChild.childNodes.length;
pics = new Array();
for (var i = 0; i < num; i++) {
pics[i] = xml.firstChild.childNodes[i].attributes.image;
}
trace(pics[1]); <<< this works
}
trace(pics[1]); <<< this one doesn`t
|