Adobe AIR应用程序在ADL上运行正常,但在单独运行时崩溃

时间:2014-10-06 15:27:14

标签: actionscript-3 flash air adobe

我正在为Adobe AIR开发一个应用程序。当我通过ADL运行时,该应用程序在Adobe Flash CC上正常工作。当我发布桌面应用程序并运行它时,我收到以下错误: VerifyError:错误#1014:找不到类flash.filesystem :: File。

这很奇怪,因为实际上,当我在Adobe Flash之外运行应用程序时,该应用程序通过Flash Player运行。

导致问题的代码是:

import flash.filesystem.File;
import flash.filesystem.FileStream;
import flash.filesystem.FileMode;

function saveData(): void {
    var pathToFile: String = File.documentsDirectory.resolvePath('test.txt').nativePath;
    var someFile: File = new File(pathToFile);
    var stream: FileStream = new FileStream();
    stream.open(someFile, FileMode.WRITE);
    stream.writeUTFBytes(csv);
    stream.close();
}

它崩溃了

var pathToFile: String = File.documentsDirectory.resolvePath('test.txt').nativePath;

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

您必须发布Adobe AIR应用程序而不仅仅是" SWF"文件。

消息:

VerifyError: Error #1014: Class flash.filesystem::File could not be found.

表示您的SWF不是从AIR执行,而是从简单的Flash Player执行。

您必须为桌面设置T​​arget AIR(也可以下载最新的AIR SDK),如下所示:

enter image description here

您也可以选择分发应用程序的方式:

enter image description here

我建议使用"应用程序嵌入运行时"因为在这种情况下,您将收到包含所有运行时的应用程序,您的用户不会对您的软件造成任何不便。

相关问题