Hi,
I was wondering if I’m using Future the right way to save a file. Thank you for your feedback!
private function _export_levels():Void {
//I need this ENTER_FRAME to see where the export is at,
//because it's doing the export in one long frame
Lib.current.stage.addEventListener(Event.ENTER_FRAME, update_export);
var create_export_file = new Future(function(){
//
//Creating a big String that will go into a JSON file
//
//Not sure what to return...
//Anything seems to work to tell the function that I'm done
return true;
}, true);
create_export_file.onComplete(function(future) {
Lib.current.stage.removeEventListener(Event.ENTER_FRAME, update_export);
//A second "Future" to save a temp file for safety
var save_file = new Future(function() {
File.saveContent(path + "temp", levels_to_export);
return true;
}, true);
save_file.onComplete(function(future) {
//Deleting the old file
if (FileSystem.exists(path + file_name) == true) {
FileSystem.deleteFile(path + file_name);
}
//Renaming the temp file to the actual save file
FileSystem.rename(path + "temp", path + file_name);
});
});
}
Thank you for all the help everyone!