public function downLoad(sourceurl:String,targetfile:String):void{
    var loader:URLLoader = new URLLoader();
    loader.dataFormat = URLLoaderDataFormat.BINARY;
    loader.addEventListener(Event.COMPLETE,
     function(e:Event):void
     {
      var airf:File =File.applicationStorageDirectory.resolvePath(targetfile);
      trace(airf.nativePath);
      //trace(airf.url);
      var fs:FileStream = new FileStream();
      fs.open(airf, FileMode.WRITE);
      fs.writeBytes(loader.data);
      fs.close();
      airf.downloaded = true;          
      //打开此下载完成的文件
      airf.openWithDefaultApplication();
     });
    loader.addEventListener(ProgressEvent.PROGRESS,function(e:ProgressEvent):void{
     trace(e.bytesLoaded/e.bytesTotal+"/"+100);
    });
    var req:URLRequest = new URLRequest(sourceurl);
    loader.load(req);
   }

相关文章:

  • 2021-12-03
  • 2021-11-20
  • 2021-10-26
  • 2022-01-30
  • 2022-01-04
  • 2022-02-09
  • 2021-07-15
猜你喜欢
  • 2021-11-29
  • 2021-11-20
  • 2021-04-03
  • 2021-12-23
  • 2022-01-06
  • 2021-12-23
  • 2021-11-16
  • 2021-10-03
相关资源
相似解决方案