开发者

Save Data in Adobe Flash Desktop App

I am making a desktop Flash application (AS3). It provides to users an opportunity to save and open their p开发者_如何学编程rojects. I've used FileReference to open project file

var fileRef:FileReference = new FileReference();
var ourTypes:Array=new Array(new FileFilter("Map Editor type (*.xml)", "*.xml"));
fileRef.browse(ourTypes);

and use file content by using fileRef.data.

var mainXml:XML;
mainXml=new XML(fileRef.data);

User must have an opportunity to add some data in this file (not only read). How can I save new data in the same file?


You can save a file via fileRef.save( data:*, defaultFileName:null), where data is the data object you want to save, in your case mainXML.toString(). This will always open another file dialog, unfortunately, and there's no way to work around it, since it seems to be a security restriction. The only thing you can do is provide a defaultFileName, so the user doesn't have to enter one manually.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜