Hi guys, i am having a wierd problem with setting some global vars from a dynamically loaded xml file. When the xml is loaded i am starting a function to store the data in some global vars, when i trace the global var within the function, the trace works perfectly. But however if i try to trace it on the root, the trace comes out undefined.
i have tried all sort of things but nothing comes in mind to fix it, maybe you guys can help me.
heres the code
attached are the files
AS:Code
var Conf = new Array();
xmlConfig = new XML();
xmlConfig.ignoreWhite = true;
xmlConfig.onLoad = loadConfigXML;
xmlConfig.load("config.xml");
function loadConfigXML(loaded) {
if (loaded) {
this.smartparser(Conf);
} else {
content = "where is the xml?!";
}
loadUrls();
}
//------------------------------------------------------------------
// XML SMARTPARSER
//------------------------------------------------------------------
XML.prototype.smartparser = function(holder) {
for (this.n=0; this.n<this.firstChild.childNodes.length; this.n++) {
this.Item = this.firstChild.childNodes[this.n];
if (this.Item.nodeName == "topfeature" or this.Item.nodeName == "dsk01" or this.Item.nodeName == "dsk02" or this.Item.nodeName == "promos" or this.Item.nodeName == "musicplayer") {
if (this.Item.firstChild.nodeType == 3) {
holder.push(this.Item.firstChild.nodeValue);
//holder[this.Item.nodeName] = this.Item.firstChild.nodeValue;
} else {
if (this.Item.nodeValue == null) {
tmp = holder[holder.length]=new Array();
newxml = new XML(this.Item);
newxml.smartparser(tmp);
}
}
} else {
if (this.Item.firstChild.nodeType == 3) {
//holder.push(this.Item.firstChild.nodeValue);
holder[this.Item.nodeName] = this.Item.firstChild.nodeValue;
} else {
if (this.Item.nodeValue == null) {
tmp = holder[holder.length]=new Array();
newxml = new XML(this.Item);
newxml.smartparser(tmp);
}
}
}
}
};
//------------------------------------------------------------------
function loadUrls() {
_global.topfeature = Conf[0];
_global.dsk01 = Conf[1];
_global.dsk02 = Conf[2];
_global.promos = Conf[3];
_global.musicplayer = Conf[4];
trace(_global.topfeature);
}
trace(_global.topfeature);
stop();
XML:Code
<config>
<topfeature>http://192.168.0.2/cms/topfeature.php</topfeature>
<dsk01>http://192.168.0.2/cms/section.php</dsk01>
<dsk02>http://192.168.0.2/cms/content.php</dsk02>
<promos>http://192.168.0.2/cms/promos.php</promos>
<musicplayer>http://192.168.0.2/tone.php?id=</musicplayer>
</config>