我有一个在iPad上运行的Flex应用程序(SDK 4.5.1)...我需要下载任何文件,将它们放在本地目录(如File.applicationStorageDirectory)中,然后查看我的应用程序中的文件.
所以在我的测试应用程序中,使用urlLoader类下载了一个png图像.
这是下载的完整处理程序:
private function onComplete3(event:Event):void{
try{
var ba:ByteArray = event.target.data as ByteArray;
var file:File=File.applicationStorageDirectory.resolvePath("img.png");
var pathFile:String = file.nativePath;
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.WRITE);
fileStream.writeBytes(ba);
fileStream.addEventListener(Event.CLOSE, fileClosed);
fileStream.addEventListener(IOErrorEvent.IO_ERROR,function(e:IOErrorEvent):void{
status0.text = "STATE : ERROR 3"
});
fileStream.close();
status0.text = "STATO : OK";
path0.text = pathFile;
immagine0.source = pathFile;
catch(e:Error){
status0.text = "STATE : ERROR 2"
}
}
Run Code Online (Sandbox Code Playgroud)
在我的iPad上,我可以看到下载的文件存在,但是当我运行immagine0.source = pathFile(这是一个图像组件)时,没有任何东西出现......也许我可以写一个文件,但我看不懂它?