1 Reply Latest reply on Oct 31, 2006 2:15 PM by ntsiii

    Read external xml file


      I want to load (some of the) content of an xml file into an array. (actionscript in FLEX)

      I found an example at the flex documentation ( over here

      but when i try this examle:

      var myXML:XML = new XML();
      var XML_URL:String = "http://www.example.com/Sample3.xml";
      var myXMLURL:URLRequest = new URLRequest(XML_URL);
      var myLoader:URLLoader = new URLLoader(myXMLURL);
      myLoader.addEventListener("complete", xmlLoaded);

      function xmlLoaded(evtObj:Event) {
      myXML = XML(myLoader.data);
      trace("Data loaded.");


      i get two errors:
      - 1120: Acces of undifined property myLoader.
      - 1120: Acces of undifined property mxLoaded

      Can anyone tell me how i can solve this problem?
        • 1. Re: Read external xml file
          ntsiii Level 3
          You can't do all that stuff outside a function. The variables do not exist until they all have been created during the object instantiation.

          Declare the variables in the global scope, then do the value assignments in a function, say initApp(), that you call in the creationComplete event on the Application tag.