I am making a desktop Flash application (AS3). It provides to users an opportunity to save and open their projects.
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), wheredatais the data object you want to save, in your casemainXML.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 adefaultFileName, so the user doesn’t have to enter one manually.