Welcome, Guest. Please login or register.
Did you miss your activation email?
31 Jul 2010, 11:31:57 UTC
Forum home
+  flexdeveloper.eu Forum
|-+  Flex and ActionScript 3.0
| |-+  ActionScript 3.0 (Moderators: JMWhittaker, Jan K, thewarpedcoder, James)
| | |-+  Loading External XML
« previous next »
Pages: [1] Print
Author Topic: Loading External XML (Read 10893 times)
MadamZuZu
Newbie FD
*
Posts: 53


Xrum!


WWW
« on: 13 Jul 2007, 20:43:49 UTC »

why is it when i do this:

Code:

var myXML:XML = new XML();
var XML_URL:String = "skn_organ.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);

public function xmlLoaded(evtObj:Event):void
{
        myXML = XML(myLoader.data);
}


myLoader and xmlLoader are undefined (when i compile)

am i forgeting something?


Thanks!
Logged

(http://www.xrumxrum.com/forum/richedit/smileys/2.gif)Xrum!
flexy
flexdeveloper.eu
Guru/Addict FD
*****
Posts: 3,155


Recovering Coffee Addict & Adobe Expert


WWW
« Reply #1 on: 16 Jul 2007, 12:38:59 UTC »

I can't see any reference to 'xmlLoader' in your code  :-/

I also don't see the load() method of myLoader that invokes the actual server call.

You probably need it to look more like:

Code:
private var myXML:XML = new XML();

private function createLoaderOperation() :void
{
    var myLoader:URLLoader = new URLLoader();
    myLoader.addEventListener( "complete", xmlLoaded );
    myLoader.load( URLRequest( "skn_organ.xml" );
}

private function xmlLoaded( p_event:Event ) :void
{
    myXML = XML( p_event.currentTarget.data );
}
« Last Edit: 16 Jul 2007, 12:40:11 UTC by flexy » Logged

MadamZuZu
Newbie FD
*
Posts: 53


Xrum!


WWW
« Reply #2 on: 17 Jul 2007, 15:29:34 UTC »


i'm goign crazzzzy here.


i have a list, that reads XML.
i want that list to update on production without me having to build the project all the time, but by just uploading a new XML file.

i think the function i need is this:
Code:
        private function LoadMyXML():void
          {
                var myXML:XML = new XML();
                  var XML_URL:String = "xml/AO_Other.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.");
                  }
          }

my xml looks like this:
Code:
<AO_OTHER>
      <category title="Administrative Groups">
            <link title="Administrative Groups" url="sadfsf"/>
      </category>      
      <category title="AO Survey Results">
            <link title="AO Survey Results" url="sdfsdf202.pdf"/>
      </category>
</AO_OTHER>
and the error i keep getting is htis:

TypeError: Error #1090: XML parser failure: element is malformed.
      at TabTest/private:LoadMyXML/xmlLoaded()[C:\Flex\SearchTest\TabTest.mxml:25]
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at flash.net::URLLoader/flash.net:URLLoader::onComplete()



Sad
what am i doing wrong?
am i even going though this the right way?

thanks!
Logged

(http://www.xrumxrum.com/forum/richedit/smileys/2.gif)Xrum!
flexy
flexdeveloper.eu
Guru/Addict FD
*****
Posts: 3,155


Recovering Coffee Addict & Adobe Expert


WWW
« Reply #3 on: 17 Jul 2007, 17:24:09 UTC »

Don't nest functions inside functions; it's bad practice and will cause you problems in the long-run.
Logged

MadamZuZu
Newbie FD
*
Posts: 53


Xrum!


WWW
« Reply #4 on: 17 Jul 2007, 17:50:36 UTC »

ok
so i'v decided to go this way:

Code:
<mx:HTTPService id="Quick" url="xml/AO_Quick.xml"


but now there's some other issues. i'll post more once i work on it a little more
Logged

(http://www.xrumxrum.com/forum/richedit/smileys/2.gif)Xrum!
Pages: [1] Print
« previous next »
Share this on: Twitter Twitter Del.icio.us del.icio.us Digg Digg
Jump to:

©2006-2010 Flexdeveloper.eu/Jodie O'Rourke. All rights reserved.
Adobe®, Adobe® Flash™, Adobe® AIR™ and Adobe® Flex™ are registered trademarks of Adobe Systems Incorporated in the United States and other countries. All rights reserved.

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC