1

我正在使用 as3 air 并在 android 上进行测试。

我需要能够通过浏览功能加载 sd 卡,或者 我需要通过路径直接指向该文件夹。

我已成功从服务器下载了一个 zip 文件。我可以在桌面上测试时解压缩它,因为我可以在桌面上浏览到正确的路径,但不能在手机上浏览。但我现在不需要浏览功能。我只需要能够指向 applicationStorgeDirectory 和其中的文件。:)

我需要文件 var :)

var reader:ZipFileReader = new ZipFileReader();
    reader.open(file); /// Help :)

更新 2012 年 9 月 4 日下午 5 点


我试过这段代码:

var file:File = File.applicationStorageDirectory.resolvePath("myFile.zip");
trace(file.url); //path to the file
//assuming that function takes a string path
reader.open(file.url);

我得到了这个错误:

Scene 1, Layer 'Layer 1', Frame 1, Line 46
1067: Implicit coercion of a value of type String
to an unrelated type flash.filesystem:File.
4

2 回答 2

4

这应该给你一个现有文件的 url

文件网址

你可以尝试这样的事情:

var file:File = File.applicationStorageDirectory.resolvePath("myFile.zip");
trace(file.url); //path to the file
//assuming that function takes a string path
reader.open(file.url);
于 2012-09-04T23:27:27.257 回答
1

试试下面的。我已经测试过了。

var file:File = File.applicationStorageDirectory.resolvePath("myFile.zip");
trace(file.url);
reader.open(file);
于 2012-09-05T02:29:35.133 回答