PDA

View Full Version : Flex Reading local XML file



AlexWeldon
August 1st, 2008, 04:27 PM
Hi, I'm having a problem with Flex. When I make a Flex app that reads a local XML file, it works when I run it from the bin-debug directory, and it works when I run it from my website, but if I copy it to another directory on my hard disk (along with the XML file), it can no longer open the XML file... even if I copy the entire bin-debug directory and paste it directly into another folder on my hard drive, when I open the HTML file (with the call to the SWF file) in my browser, the app loads up successfully, but it behaves as if the XML file isn't there.

I guess it must be a permissions thing, but if it works from the bin-debug directory, there must be a way to make it work in other directories. It's important, because I'm making an engine for browser-based point-and-click adventure games, and I need the game developers to be able to keep a local copy of the SWF to test out their game as they're making it, without needing to upload it to a website.

I'm on a PPC Mac G5, running OS 10.4.11

Here's an example of the way I'm reading the XML files, in case that makes a difference.:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:All="*" layout="absolute" creationComplete="startup();">

<mx:Script>
<![CDATA[
var my_req:URLRequest = new URLRequest("test_xml.xml");
var loader:URLLoader;

public function startup():void {
loader = new URLLoader(my_req);
loader.addEventListener(Event.COMPLETE,eventhandle r);
}

public function eventhandler(ev:Event):void {
testtext.text = XML(loader.data).string;
}
]]>
</mx:Script>

<mx:Text id="testtext" />

</mx:Application>

skial
August 2nd, 2008, 06:29 AM
Hi, try this link, LINK (http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html), select the icon with a pad lock in front of a globe, then select the folder that has the xml file and all the rest of the site in it and save.

Cheers:beer:

Skial

AlexWeldon
August 2nd, 2008, 10:46 AM
Hi, try this link, LINK (http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html), select the icon with a pad lock in front of a globe, then select the folder that has the xml file and all the rest of the site in it and save.


Works like a charm, thanks! Why wouldn't they allow you access to those options via the right-click "Flash player settings" menu, though? Oh well, now I know.