2019-11-20 zhulinan Flash
... ... private function btn1ClickHandle(e:MouseEvent):void { var rt:File = File.documentsDirectory.resolvePath("/sdcard/data/elight/test/"); var url:String = rt.url + "/" + "dh.swf"; var file:File = new File(url); addMsg(url); if(file.exists) { addMsg("文件存在"); loadSwf(url); } else { addMsg("文件不存在"); loadFile(url, loadSwf); } } private function loadFile(url:String, fun:Function):void { var loader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.BINARY; //用二进制的方式读取 configureListeners(loader); loader.addEventListener(Event.COMPLETE, function(e:Event){lfCompleteHandle(e, url, fun)}); var request:URLRequest = new URLRequest("https://hi.oss-cn-hangzhou.aliyuncs.com/test/dh.swf"); try { loader.load(request); } catch (error:Error) { trace("Unable to load requested document."); } } private function lfCompleteHandle(e:Event, url:String, fun:Function):void { var file:File = new File(url); var ba:ByteArray = e.target.data as ByteArray; var fileStream:FileStream = new FileStream(); fileStream.open(file, FileMode.WRITE); fileStream.writeBytes(ba); fileStream.close(); fun(url); } ... ...