1 Reply Latest reply on Jun 28, 2006 11:13 AM by Rothrock

    XML onLoad problem

      I'm calling an external xml file and loading it into Flash.

      I can only pull the varables out in the onLoad function. Here it is.

      var courseXML:XML = new XML();
      courseXML.ignoreWhite = true;

      courseXML.onLoad = function(bSuccess:Boolean):Void {
      if (bSuccess && this.status == 0) {
      var xnRoot:XMLNode = new XMLNode(3, this.firstChild);
      var xnHelpText:XMLNode = new XMLNode(3,
      else {
      trace("document failed to load or parse.");



      All these trace statements produce the desired result.

      However, I can't get the data out and available globally. In other words, I want the same variable statements to exist outside the onLoad function call, so that I can actually use the data. Anybody know how to do this?

        • 1. Re: XML onLoad problem
          Rothrock Level 5
          That is because that is what you are telling Flash to do. Any variable declared with "var" is going to be local to the function where it is created. So your choice is to drop var. But of course if you truly want a global variable, then declare it as a _global variable!

          PS: The courseXML object is its own object and exists outside the onLoad event handler function. Once it is loaded it stays there until you remove it. So the data is there an freely available even after it loads.