2010-05-04 154 views
1

Fzip LIB我目前正在针对Adobe AIR(1.5.3)的一个项目,我需要解压缩文件,它的一些内容复制到另一个文件。使用下的Adobe AIR应用程序

然后,我看到人们在谈论Fzip(http://codeazur.com.br/lab/fzip)库。问题是我不知道如何“导入”或使用Javascript和Adobe Air这个库,因为Javascript没有导入指令。

我该如何设法做到这一点?

回答

1

我发布了一个演示如何在Adobe Air和Javascript中使用FZip。我希望它希望为你清除一些事情。

总之你需要拉SWF文件进行编译的SWC(如适用)和访问类。

演示是非常简单,其实只是一个概念验证,但你应该能够轻松地扩展它。

http://www.drybydesign.com/2010/05/12/adobe-air-fzip-without-flex/

-Ari

+0

如此简单,如此难以找到解决方案。 阿里,非常感谢!我会传播这个'单词'。 – 2010-05-13 19:00:11

1

Ari的例子是相当不错的,它让我开始了,但他留下了一些非常重要的东西 - 喜欢写的未压缩的文件回磁盘。而且zip文件不必远程托管 - 有关AIR的东西就是它像本地应用程序一样运行......这是一个基于Ari给我们的良好开端的示例。 (我使用HTML5只是要冷静,髋关节和现代!) -

<!DOCTYPE HTML> 
<html> 
<head> 
    <title>Test Fzip</title> 
<script type="application/x-shockwave-flash" src="scripts/fzip.swf"></script> 
<script type="text/javascript" src="scripts/AIRAliases.js"></script> 
<script type="text/javascript" src="scripts/AIRIntrospector.js"></script> 
<script type="text/javascript" src="scripts/jquery-1.4.2.js"></script> 
<script type="text/javascript"> 
     var fzip; 
     if (window.runtime) { 
      if (!fzip) 
       fzip = {}; 
       fzip.FZip = window.runtime.deng.fzip.FZip; 
       fzip.FZipFile = window.runtime.deng.fzip.FZipFile; 
     } 
     var file = air.File.documentsDirectory.resolvePath("test.zip"); 
     //file.url 
     var zip = new fzip.FZip; 
     zip.addEventListener(air.Event.OPEN, onopen); 
     zip.addEventListener(air.Event.COMPLETE, oncomplete); 
     zip.load(new air.URLRequest(file.url.toString())); 

     function oncomplete(event) { 
      var count = zip.getFileCount(); 
         alert(count); 

      for (var idx = 0; idx < count; idx++) 
      { 
       var zfile = zip.getFileAt(idx); 
       // alert(zfile.filename); 
       var uzfile = air.File.applicationStorageDirectory.resolvePath(zfile.filename); 
       var stream = new air.FileStream(); 
       stream.open(uzfile, air.FileMode.WRITE); 
       stream.writeBytes(zfile.content,0, zfile.content.length); 
       stream.close(); 
      } 

     } 

     function onopen(event) { 
      alert("file is opened"); 
     } 
</script> 
</head> 
    <body> 


    </body> 
</html> 
相关问题