我在主机上获取文件内容并通过以下函数保存文件:
protected function fileDownload(fileName:String):void
{
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onCompleteFileDownload);
loader.load(new URLRequest("http://samed.us/"+fileName));
}
private function onCompleteFileDownload(e:Event):void
{
saveFile("test.jpg",URLLoader(e.target).data);
}
private var Depo:File = File.documentsDirectory.resolvePath("testFiles");
private function saveFile(fileName:String, content:String):void
{
var file:* = Depo.resolvePath(fileName);
var stream:FileStream = new FileStream()
stream.open(file, FileMode.WRITE);
stream.writeUTFBytes(content);
stream.close();
}
例如,可以显示此图像。但是功能是通过中断下载和写入。
怎么修?