# Wierd global vars problem

**URL:** <https://forum.kirupa.com/t/wierd-global-vars-problem/188014>\
**Category:** flash\
**Created:** [May 3, 2006, 7:54pm UTC](https://forum.kirupa.com/t/wierd-global-vars-problem/188014 "2006-05-03T19:54:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![drop2](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@drop2](https://forum.kirupa.com/u/drop2)\
**Post date:** [May 3, 2006, 7:54pm UTC](https://forum.kirupa.com/t/wierd-global-vars-problem/188014/1 "2006-05-03T19:54:20Z")

</div>

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

```auto

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

```auto

<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>

```
