Try this (tested and works here);

I think the main issue was that you were not importing the classes. I changed a few other things also. Let me know if this doesn't run, or if you have questions.

------
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml";
        creationComplete="onCreationComplete()">

     <mx:Script><![CDATA[
         import mx.formatters.*;
         import flash.net.URLRequest;
         import flash.net.URLLoader;

        var myXML:XML;
        var myXMLURL:URLRequest;

        private function onCreationComplete():Void
        {
                myXML = new XML();

                myXMLURL = new URLRequest("data.xml");
                var myLoader:URLLoader = new URLLoader(myXMLURL);
                myLoader.addEventListener("complete", xmlLoaded);
        }

        private function xmlLoaded(evtObj:Event) {
                  myXML = XML(evtObj.target.data);
          trace("Data loaded.");
        }
        ]]>
    </mx:Script>
</mx:Application>
----------

mike chambers

[EMAIL PROTECTED]

Merrill, Jason wrote:
Thanks Mike, but I tried your script and got the exact same compiler
errors.  Ultimately what I am trying to do is bind some XML data into a
pie chart.  I have the pie chart working fine, but the data is just hard
coded into an Actionscript object, and I would like to use XML instead.
Any ideas?

So, the data.xml and the mmxl file are in the same folder, and the XML
file is called data.xml - and just contains 3-4 simple XML nodes.

Jason Merrill   |   E-Learning Solutions   |  icfconsulting.com











-----Original Message-----
From: [EMAIL PROTECTED] [mailto:flashcoders-
[EMAIL PROTECTED] On Behalf Of Mike Chambers
Sent: Wednesday, October 19, 2005 2:02 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Help with Flexbuilder 2 and XML loading

This should work (havent compiled, so might have a typo or two).

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml";
        creationComplete="onCreationComplete()">

   <mx:Script><![CDATA[
       import mx.formatters.*;
       [Bindable]

        var myXML:XML;
        var XML_URL:String

        private function onCreationComplete():Void
        {
                myXML = new XML();
                XML_URL = "data.xml";
                myXMLURL = 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.");
        }
      ]]>
  </mx:Script>
</mx:Application>

mike chambers

[EMAIL PROTECTED]



Merrill, Jason wrote:

I'm trying to load in an XML file in Flexbuilder 2, but I get

errors.

My file "data.xml" is in the same folder as "test1.mxml".

The errors are:

Access of undefined property myLoader   test1.mxml      test1

line 11

Access of undefined property xmlLoaded test1.mxml       test1   line 12

Here is the script test1.mxml:

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml";>

   <mx:Script><![CDATA[
       import mx.formatters.*;
       [Bindable]

        var myXML:XML = new XML();
        var XML_URL:String = "data.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.");
        }
      ]]>
  </mx:Script>
</mx:Application>

Any idea what I am doing wrong?  I followed the examples in the

docs.

Thanks.

Jason Merrill   |   E-Learning Solutions   |  icfconsulting.com



NOTICE:
This message is for the designated recipient only and may contain

privileged or

confidential information. If you have received it in error, please

notify the sender

immediately and delete the original. Any other use of this e-mail by

you is

prohibited.

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to