[英]Create Temp XML File With ActionScript
I would like to locally save an XML file with ActionScript, as a temp file, if at all possible. 我想尽可能地将带有ActionScript的XML文件本地保存为临时文件。 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? 我已经阅读了所有有关AS如何在没有对话框的情况下不允许您执行此操作的信息(并且我了解安全问题),但是肯定必须有某种临时选项吗? I need to dynamically generate some XML to pass to another swf using URLVariables
(I have no control over this part). 我需要动态生成一些XML,以使用URLVariables
传递到另一个SWF文件(我对此部分没有控制权)。 Right now, I can only pass in previously created XML files. 现在,我只能传递以前创建的XML文件。
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. 我想用我创建的xml替换us/data.xml
。
You should be able to pass the XML object directly through the URLRequest
or the URLVariables
object. 您应该能够直接通过URLRequest
或URLVariables
对象传递XML对象。 Something like: 就像是:
var x:XML = ...;
var req:URLRequest = new URLRequest( url )
req.data = xml;
ldr.load( urlReq );
If the xml is large, then you can compress it with a ByteArray
: 如果xml大,则可以使用ByteArray
对其进行压缩:
var x:XML = ...;
var bytes:ByteArray = new ByteArray;
bytes.writeUTFBytes( x );
bytes.compress();
var req:URLRequest = new URLRequest( url )
req.data = bytes;
ldr.load( urlReq );
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/ 如果遇到问题,则可能需要使用Base64对其进行编码,在这种情况下,可以使用以下库: 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 or SharedObject.getRemote()
(requires Flash Media Server): http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/SharedObject.html#getRemote () 另外,您是否还查看过LocalConnection
: http : //help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/net/LocalConnection.html或SharedObject.getRemote()
(需要Flash Media Server) : http : //help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/net/SharedObject.html#getRemote ()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.