Flash 空气,加载本地存储的图像

Flash 空气,加载本地存储的图像,flash,air,Flash,Air,我打包了一个IPA文件,其中包括一些资产(图像)。安装后,我想在我的swf中加载一个映像:该映像的路径是什么?如何加载它?如果打包了资产文件夹,则安装应将其内容包含在文件.applicationDirectory.resolvePath(“./assets/”)文件夹中 您可以通过file.applicationDirectory.resolvePath(“./assets/myImage.png”) 要将文件读取到字节数组 var f:File=File.applicationDirector

我打包了一个IPA文件,其中包括一些资产(图像)。安装后,我想在我的swf中加载一个映像:该映像的路径是什么?如何加载它?

如果打包了资产文件夹,则安装应将其内容包含在
文件.applicationDirectory.resolvePath(“./assets/”)
文件夹中

您可以通过
file.applicationDirectory.resolvePath(“./assets/myImage.png”)

要将文件读取到字节数组

var f:File=File.applicationDirectory.resolvePath("./assets/myImage.png");
var fs:FileStream=new FileStream();
var ba:ByteArray=new ByteArray();

fs.open(f, FileMode.READ);
fs.readBytes(ba);
//unsure about this, also try CompressionAlgorithm.DEFLATE
ba.uncompress(CompressionAlgorithm.ZLIB); //uncompresses the byteArray
fs.close();

现在,您将在byteArray中获得图像文件的字节。

最后,我使用常规URLRequest(“资产/”+fileToLoad)加载了图像。ByteArray有任何性能改进吗?我没有尝试过,但是如果您只使用1,我认为不应该有任何显著的性能改进