Flash Actionscript 3 saving a XML file locally has a “Save As” window (How can I remove it?)

痴心易碎 提交于 2019-12-25 03:40:12

问题


So, I have a flash application that handles several client profiles for a company. Whenever a new client profile is created, it saves a new XML file localy. My problem is that instead of doing a "silent" file creation, a window pops up just like doing a "Save As" as to confirm that the file is being saved on disk and which name should it be.

Is there a way to do a file save within flash without it calling out that window? If so, would it be possible to link me to an example of it?

Here is an example of my code:

var xmltosave:XML = new XML ( "<?xml version=&quot1.0&quot encoding=&quotutf-8&quot?><cliente><id>"+idfield.text+"</id><nome>"+nomefield.text+"</nome><tipo>"+tipofield.text+"</tipo><empresa></empresa><email>"+emailfield.text+"</email><contacto>"+contacto1field.text+"</contacto><contacto2>"+contacto2field.text+"</contacto2><profissao></profissao><datainscricao>"+datafield.text+"</datainscricao><dataalteracao></dataalteracao><notas></notas><notas2></notas2><notas3></notas3></cliente>");

var file:FileReference = new FileReference;
var filepath:String = new String(idfield.text + ".xml");
file.save( xmltosave, filepath );

Also, I know that the xmltosave is very long, is it possible to do line breaks in AS3 code?

Thank you. Marco Roberto.

NOTE: I know that I should use a php script to manage files, but unless that php is able to run locally without any server installs, like XAMPP, im not interested in using it. This is a small project and I just need to handle XML files. Unless its absolutely impossible to do it without PHP scripts, I would prefer a AS3 solution.


回答1:


since you're building a desktop application you can use flash.filesystem.File, which is part of the AIR SDK, to save files as a background process.



来源:https://stackoverflow.com/questions/7379649/flash-actionscript-3-saving-a-xml-file-locally-has-a-save-as-window-how-can-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!