sarcus25
Programmer
- Apr 14, 2005
- 27
Hi, I'm trying to create a global array that will hold a list of values that it retrives from an xml file. The global array values can only be traced inside the for loop. I am not able to access the array outside of the for loop. Here is the code used. Thanks in advance.
Code:
//initial values
//==============
_global.songName = new Array();
_global.songAdded = new Array();
aSwitch = true;
//Striping the xml data and putting it into arrays
//==================================================
function XMLOut(xml_file):Void{
for (var i=0;i < xml_file.firstChild.childNodes.length; i++){
for (var j=0; j < xml_file.firstChild.firstChild.childNodes.length;j++){
if (aSwitch){
_global.songName.push(xml_file.firstChild.childNodes[i].childNodes[j].firstChild.nodeValue);
aSwitch = !aSwitch;
trace("inside for loop SongName: " + i + " " + _global.songName[i]);]);//Returns the Song Name
}
else{
_global.songAdded.push(xml_file.firstChild.childNodes[i].childNodes[j].firstChild.nodeValue);
aSwitch = !aSwitch;
trace("inside for loop SongAdded: " + i + " " + _global.songAdded[i]);//Returns the Date the song was added
}
}
}
}
trace(_global.songName[0]);//Displays undefined
trace(_global.songAdded[0]);//Displays undefined