Actionscript 3 空气>;避免奇怪的行为

Actionscript 3 空气>;避免奇怪的行为,actionscript-3,air,Actionscript 3,Air,我只是在我的应用程序中发现了一些奇怪的东西 我有一个“保存”按钮,可以触发此功能: var saveFile:File = File.desktopDirectory.resolvePath(nameOfProject+".uct"); saveFile.browseForSave("Save as"); saveFile.addEventListener(Event.SELECT, saveFileToSystem); 单击后,将显示“浏览保存”窗口,其中包含建议的文件名。 现在我注意

我只是在我的应用程序中发现了一些奇怪的东西

我有一个“保存”按钮,可以触发此功能:

 var saveFile:File = File.desktopDirectory.resolvePath(nameOfProject+".uct");
 saveFile.browseForSave("Save as");
 saveFile.addEventListener(Event.SELECT, saveFileToSystem);
单击后,将显示“浏览保存”窗口,其中包含建议的文件名。 现在我注意到,在导出、安装和运行应用程序时,当我第一次单击按钮时,一切正常,但当我再次单击时,位置如下所示:

var saveFile:File = File.documentsDirectory.resolvePath("output.file");
var tempMovedAway:File = File.applicationStorageDirectory.resolvePath("temp.temp");
currentFileRenamedForAirBug = picker.clone();
currentFileRenamedForAirBug.moveTo(tempMovedAway), true);
saveFile.addEventListener(Event.SELECT, function():void {
        tempMovedAway.deleteFile();
    } );
saveFile.addEventListener(Event.CANCEL, function():void {
        tempMovedAway.moveTo(currentFileRenamedForAirBug);
    });
saveFile.browseForSave("save file"); 
// MUST be sure to call saveFile.browseForSave, or you risk losing an existing file.

“where”字段是同一个文件。。。。?即使我点击save,它也不会保存。奇怪的是,在FlashBuilder中测试我的应用程序时,这并没有发生。
有什么提示吗?

我做了上面的解决方法,它似乎起到了作用。代码是这样的:

var saveFile:File = File.documentsDirectory.resolvePath("output.file");
var tempMovedAway:File = File.applicationStorageDirectory.resolvePath("temp.temp");
currentFileRenamedForAirBug = picker.clone();
currentFileRenamedForAirBug.moveTo(tempMovedAway), true);
saveFile.addEventListener(Event.SELECT, function():void {
        tempMovedAway.deleteFile();
    } );
saveFile.addEventListener(Event.CANCEL, function():void {
        tempMovedAway.moveTo(currentFileRenamedForAirBug);
    });
saveFile.browseForSave("save file"); 
// MUST be sure to call saveFile.browseForSave, or you risk losing an existing file.
您可以仅在检查Air运行时(NativeApplication.NativeApplication.runtimeVersion)和Mac时包装这一部分,以避免执行超出必要的操作


此外,如果您的文件保存代码可以依赖于对现有文件进行更改(而不是创建一个全新的文件),则需要对其进行一些调整。

这是一个错误,据我所知,在较新版本的Air中是新的—不确定它在何处更改,但在Air 3.4.0.2540中会发生这种情况。旧版本正确地将“Where”显示为目录。进一步检查:它在Air 3.2.0.2070中按预期工作,但在3.3.0.3670/3.4.0.2540/3.4.0.2710中被破坏;bugbase的电话号码是3345174。只有当输出文件已经存在时才会发生这种情况(即,第二次),因此一种潜在的解决方法是在“保存”发生时将输出文件临时重命名为其他文件,然后如果用户取消将其重命名,或者如果用户保存文件的新版本,则删除已重命名的旧文件。不过,这对我来说似乎有点冒险。