4 Replies Latest reply on Mar 12, 2009 5:09 AM by

    Help with Actionscript error

      What I will be trying to acheive is to read from an XML file that will be located in my assets folder in my Project directory.

      So as I will try to use the E4X concepts for obtaining data from XML, I started to write my code but am getting an error as follows: 1120: Access of undefined property contactsXMLLoader

      Here is my initial code which is giving the error on the last line:

      import flash.net.URLLoader;
      import flash.net.URLRequest;

      var contactsXMLLoader:URLLoader = new URLLoader();
      contactsXMLLoader.load(new URLRequest("assets/mydata.xml"));

      Not sure why this error is occuring?
      Also is there a way in FlexBuilder 3.0 to view the actual code of the URLLoader and URLRequest classes? Where and which files is the code contained in, if available?

      Thanks
        • 1. Re: Help with Actionscript error
          run,ryan! Level 3
          ctrl+click to trace code.
          are u sure it's that line giving the error?
          1 person found this helpful
          • 2. Re: Help with Actionscript error
            Richard_Abbott Level 3
            hkpadobe,
            recently when I saw someone else post an error of this kind, the code they were exploring with was not actually in a method of any sort but just written straight into the <mx:Script> block. Have you tried putting these lines into a method such as creationComplete() - eg
            <mx:Application creationComplete="setup_items()">

            <mx:Script>
            import flash.net.URLLoader;
            import flash.net.URLRequest;

            public function setup_items():void
            {
            var contactsXMLLoader:URLLoader = new URLLoader();
            contactsXMLLoader.load(new URLRequest("assets/mydata.xml"));
            }
            etc etc
            Richard
            • 3. Re: Help with Actionscript error
              run,ryan
              It is definately this line.

              Richard
              I'll try your suggestion and see if it works.

              Regaring my second point, is there a way to see the code for the URLLoader and URLRequest classes anyway on FlexBuilder 3.0?

              Thanks for your quick replies.
              • 4. Re: Help with Actionscript error
                Richard
                Putting the lines into a method solved the problem and the error message no longer appears.

                Thanks