I would like to locally save an XML file with ActionScript, as a temp file, if at all possible. I’ve read all about how AS won’t let you do this without dialogs (and I understand the security concerns), but surely there must be some sort of temp option? I need to dynamically generate some XML to pass to another swf using URLVariables (I have no control over this part). Right now, I can only pass in previously created XML files.
var urlReq:URLRequest = new URLRequest(url);
var variables:URLVariables = new URLVariables();
variables.data_file = "us/data.xml"; //data.xml is static/already created
urlReq.data = variables;
ldr.load(urlReq);
I would like to replace us/data.xml with xml I’ve created.
You should be able to pass the XML object directly through the
URLRequestor theURLVariablesobject. Something like:If the xml is large, then you can compress it with a
ByteArray:If you have a problem, you might need to encode it with Base64, in which case, you can use this lib: http://jpauclair.net/2010/01/09/base64-optimized-as3-lib/
Also as some alternatives, have you looked at
LocalConnection: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/LocalConnection.html orSharedObject.getRemote()(requires Flash Media Server): http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/SharedObject.html#getRemote()