Well it depends on what you're trying to do with the loaded data.
If all you want is to load it and write to disk, then the format doesn't really
matter.
As mentioned earlier, to write the loaded data to disk you use a combination of
a File instance and a FileStream instance.
Should be examples of that in the docs.
http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7e4a.html
The following will load the data, when loaded, ask where to save it, and then
write that data to the file you selected.
private var plsData:String;
private function appInit():void {
trace("Application ::: appInit");
var plsURL:String =
"http://www.funky-monkey.nl/air/stringtest/serveFile.php";
var plsReq:URLRequest = new URLRequest( plsURL );
var plsLoader:URLLoader = new URLLoader( plsReq );
plsLoader.addEventListener( Event.COMPLETE , plsLoaded );
}
private function plsLoaded(evt:Event):void {
trace("Application ::: plsLoaded");
var value:String = plsData = evt.currentTarget.data;
trace(value);
var f:File = new File();
f.addEventListener(Event.SELECT, fileSelectHandler);
f.browseForSave("Save Data");
}
private function fileSelectHandler(evt:Event):void {
trace("Application ::: fileSelectHandler");
var f:File = evt.currentTarget as File;
trace(" - nativePath: ", f.nativePath);
// create filestream, open it and write data to file
var fs:FileStream = new FileStream();
fs.open(f, FileMode.WRITE);
fs.writeUTFBytes(plsData);
fs.close();
}
----- Original Message -----
From: "Sidney de Koning" <[email protected]>
To: "Flash Coders List" <[email protected]>
Sent: Wednesday, April 22, 2009 9:44 AM
Subject: Re: [Flashcoders] Loading string data in a file from a server
No i cant use XML since eventually it will be a PLS file (Winamp
Shoutcast), I wrote a library that parses a PLS file (Playlist file
from Winamp Shoutcast server) (http://code.google.com/p/as3plsreader/)
this all works fine from with AIR, IF I have the file already saved to
local disk.
So my final test is to directly load the PLS from the shoutcast server.
That why i need to convert the event.target.data to a File... Cant i do:
var f:File = new File(event.target.data) ?
Do you have any other suggestion on how to do this?
Greets Sid
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders