I use a function like this:

 

private function loadXml(aXmlFileName:String, aResultCallBack:Function):void

{

      var xmlLoader:HTTPService;

     

      xmlLoader = new HTTPService();

      xmlLoader.resultFormat = "e4x";

      xmlLoader.url = "">

      xmlLoader.addEventListener("fault", Application.application.handleFault);

      xmlLoader.addEventListener("result", aResultCallBack);

      xmlLoader.send();

}

 

The URL ‘aXmlFileName’ follows the format "config/MasterData.xml" for example, where config is a directory in the folder where the Flex application has been downloaded from.

 

In your callback function, you can deal with the XML as follows:

 

private function handleMasterDataXmlLoaded(aEvent:ResultEvent):void

{

      var masterDataXml:XML;

      masterDataXml = aEvent.result as XML;

}

 

HTH,

Franck

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of aaron smith
Sent: Sunday, August 13, 2006 2:45 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] loading xml

 

how do I load local XML?

I was doing this:

private function loadXML():void
        {
            myXML = new XML();
            myXMLURL = new URLRequest(XML_URL);
            myLoader = new URLLoader(" menu.xml");
            myLoader.addEventListener("complete", xmlLoaded);
        }
       
        private function xmlLoaded():void
        {
            myXML = XML(myLoader.data);
            trace("Data loaded.");
        }



but it spits out errors. Is there security issues?

here are the errors..

SWF file file:///C|/Documents%20and%20Settings/aaronsh/Desktop/dev/flash/%5F%20AS3%20TESTING/3waylayout/classes/Main.swf cannot access local resource file:///C|/Documents%20and%20Settings/aaronsh/Desktop/dev/flash/%5F%20AS3%20TESTING/3waylayout/classes/menu.xml . Only local-with-filesystem and trusted local SWF files may access local resources.

Do i need to do something different for local files? I would think it would be the same as how you load from a URL...

thanks.

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





YAHOO! GROUPS LINKS




__,_._,___

Reply via email to