views:

718

answers:

3

Hello Community,

I want to have a xml file for my configuration and so i have to load it from the same directory the swf file lies in and save it afterwards. I saw articles about filestreams in flex but my compiler didn't allow me to use the filestream. I use the open source flex sdk.

anyone got an idea?

thanks in advance

Sebastian

+1  A: 

FileStream is available in Adobe AIR, not in Flex. You can't use files in Flex directly - for security reasons, you don't have access to local files (where the Flash Player is running). You'll need to fetch the data using an HTTP request.

Update: You can read the configuration using an HTTP request - if you want to save information back into the configuration, you'll have to send an HTTP POST with your changes, and have server-side logic update the configuration.

Vinay Sajip
yes local files do not interest me I need the files on server, by a http request I can't save them, am I right?
Xelluloid
A: 

Saving and file-specific operations are generally done using Java as the backend. BlazeDS is a tool that allows you to "connect" Flex with Java and vice-versa, to make them work together more efficiently (Remoting).

Aethex
A: 

Use URLLoader to load the xml. And URLLoader + PHP/ASP/whatever at the server to save it back:

var loader = new URLLoader();  
loader.addEventListener(Event.COMPLETE, onLoad);  
loader.load(new URLRequest("file.xml");  

var uploader = new URLLoader();  
var data:URLVariables = new URLVariables();  
data.xml = xml.toXMLString();  
var req:URLRequest = new URLRequest("saveXml.php");
req.data = data;  
uploader.load(req);
Amarghosh