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.
加载中,请稍侯......
精彩评论