Performing an auto-save with Adobe AIR with out a popup save box opening

爷,独闯天下 提交于 2019-12-25 06:51:05

问题


I've an AIR app that I'd like to implement a auto-save functionality. Currently I have a service that uses a timer to check the status of the current active file in my app, then if the file changes to a new file, the service checks the current file name if that has changed then the file has changed. When this happens I want to perform a auto-save, which I can do but the problem is that the save popup save box opens when the save is called, this is how I call the save function:

var file:File = File.userDirectory.resolvePath( filepath ); file.save( jsonToExport );

Is there a way to call the save() function without a popup box opening?

Thanks

Stephen


回答1:


Rather than using the File's save method, try using a FileStream to write the file directly:

var file:File = File.userDirectory.resolvePath( filepath );

//Instantiate new file stream
var fs:FileStream = new FileStream();

//add optional event listener to do some action once finished
fs.addEventListener(Event.CLOSE, fileWrittenComplete);

//open the file in write mode       
fs.openAsync(file, FileMode.WRITE);

//write your data to file   
fs.writeUTFBytes(jsonToExport);    

//close the file stream
fs.close();


来源:https://stackoverflow.com/questions/9411230/performing-an-auto-save-with-adobe-air-with-out-a-popup-save-box-opening

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