`
lxs647
  • 浏览: 516871 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Adobe AIR:压缩Zip/创建zip文件

 
阅读更多

Following up on my previous post, here's how to archive a bunch of files and make a zip file.

After getting all the files you want to put in the archive, create a new ZipEntry object for each file and add it to a ZipOutput object using the putNextEntry() of the ZipOutput class. Then pass the ByteArray data of the file to the write() method of the ZipOutput class and close the entry by using the closeEntry() method. Finally, call the finish() method once you have done the same for all the files.

Here's the code snippet :

   import flash.events.FileListEvent;
   import flash.filesystem.*;
   
   import nochump.util.zip.*;
   
   private var zipInput:File = new File();
   private var zipOutput:File = new File();
   private var zipFile:ZipOutput;
   
   private var files:Array = new Array();
   
   private function loadFiles():void
   {
    zipInput.browseForOpenMultiple("Open ZIP file");
    zipInput.addEventListener(FileListEvent.SELECT_MULTIPLE, onSelect);
   }
   
   private function onSelect(e:FileListEvent):void
   {
    for(var i:uint = 0;i < e.files.length;i++)
    {
     var stream:FileStream = new FileStream();
     var f:File = e.files[i] as File;
     stream.open(f,FileMode.READ);
     var fileData:ByteArray = new ByteArray();
     stream.readBytes(fileData);
     var file:Object = new Object();
     file.name = f.name;
     file.data = fileData;
     files.push(file);
    }
   }
   
   private function createZIP():void
   {
    zipFile = new ZipOutput();
    for(var i:uint = 0; i < files.length; i++)
    {
     var zipEntry:ZipEntry = new ZipEntry(files[i].name);
     zipFile.putNextEntry(zipEntry);
     zipFile.write(files[i].data);
     zipFile.closeEntry();
    }
    zipFile.finish();
    
    zipOutput.browseForSave("Select target directory");
    zipOutput.addEventListener(Event.SELECT, onSave);
   }
   
   private function onSave(e:Event):void
   {
    var archiveFile:File = e.target as File;
    if(!archiveFile.exists)
    {
     var stream:FileStream = new FileStream();
     stream.open(archiveFile,FileMode.WRITE);
     stream.writeBytes(zipFile.byteArray);
     stream.close();
    }
   }


As usual you can download the project archive here. Happy experimenting.

 

from: http://pradeek.blogspot.com/2009/05/creating-zip-files-with-adobe-air-with.html#comments

 

 

代码中提到的nochump lib见附件。

 

其主页如下:

 

http://nochump.com/blog/?index.html

 

友情提示:博客地址如果打不开,请FQ。◕‿◕

 

分享到:
评论
1 楼 hehailin1986_163.com 2011-10-24  
你好,我试了一下,貌似不支持中文目录的,有好方法么?

相关推荐

    hosts增强编辑小工具hostsPlus.zip

    目前已实现Windows, Mac三大平台的支持,采用Adobe Air开发,采用MIT协议发布,代码托管在github上面。 主要特色: 多文件Hosts方案管理 单Hosts文件中分组管理 绑定到机器名或域名...

    Ext 2 中文API

    使用要求:Adobe AIR虚拟机 v1.1或以上 下载地址:http://get.adobe.com/cn/air/ AIR版文档中心下载: http://www.ajaxjs.com/docs/Ext 2 API Documentation.zip ~3MB 用法:直接打开2.1 API Documentation.exe

    flash cs5.5 的 AIR3 选项

    把文件AdobeAIR3_0.xml放在 C:\Program Files (x86)\Adobe\Adobe Flash CS5.5\Common\Configuration\Players\ 另外需要 拷贝airglobal.swc 到 C:\Program Files (x86)\Adobe\Adobe Flash CS5.5\Common\...

    新浪微博air v1.14.1.zip

    微博AIR是基于Adobe AIR平台的新浪微博桌面客户端   【使用方法】 第一步:安装 Adobe AIR 运行环境(已安装的用户请跳过)http://down.chinaz.com/soft/29198.htm 第二步:安装 微博AIR (1.51) 客户端(解压后...

    air-ane-fullscreen, 在Android上,为 Adobe AIR启用 true 全屏支持.zip

    air-ane-fullscreen, 在Android上,为 Adobe AIR启用 true 全屏支持 全屏显示,适用于 Adobe AIRa的一个最常见的抱怨是,他们无法获得 true 全屏屏幕上的屏幕导航栏( 。包含背面,家庭和任务按钮的按钮) 。如果你是...

    macman_adobe air.zip

    Mac 下 图片标注工具,非常方便,体验版能满足临时需求。注意安装markman前先安装Adobe AIR

    SinaTair(微博air客户端)免费下载 v1.67.zip

    SinaTair新浪微博桌面客户端(微博air客户端)基于air平台的微博桌面客户端...A5源码友情提示:sinatair是一款基于Adobe AIR环境下的客户端软件,需要Adobe AIR环境支持,如果您未安装AIR环境请下点击下载安装:Adobe AIR

    Adobe AIR v32.0.0.125.zip

    Adobe AIR功能 基于Flash 或 Flex:应用程序根内容(理解为容器)为Flash/Flex (SWF)。 基于HTML,应用程序根内容为HTML, JS, CSS。 基于HTML的Flash/Flex或PDF,应用程序根内容为基于HTML 的Flash/Flex (SWF) ...

    Adobe AIR安装文件

    AdobeAIRInstaller.zip AdobeAIRInstaller.zip AdobeAIRInstaller.zip

    air 打包成 exe

    1. 下载Adobe官方的runtime installer ...2.解压缩zip文件,把你的安装程序放到根目录下。在根目录里新建名为 .airinstall.cfg 的文件。内容是你安装程序的名字,如MyApp.air 3. 用winRar 制作自解压文件

    AdColony-AdobeAIR-SDK:适用于Adobe AIR的AdColony本机扩展

    AdColony AIR本机扩展修改时间:2021/02/11 Android SDK版本:4.4.1 iOS SDK版本:4.5.0 本机扩展版本:4.4.0概述AdColony提供零缓冲, ,和Aurora:trade_mark:可播放广告,它们可以显示在应用程序中的任何位置。...

    restfulx_framework, 开发 Adobe Flex和AIR应用程序的RESTful方法.zip

    restfulx_framework, 开发 Adobe Flex和AIR应用程序的RESTful方法 RestfulX框架:开发 Adobe Flex和AIR应用程序的RESTful方法描述下面是你可以使用RestfulX做的一些事情:在不到 5分钟的时间内,创建完整的Adobe ...

    DevCDR:Device Commander,基于云的ClientServer管理工具

    设备指挥官(DevCDR) ...自动更新: 7-Zip,AdobeAir,AdobeReader DC,AdobeReader DC MUI,代码,FileZilla,Firefox,FlashPlayerPlugin,FlashPlayerPPAPI,GIMP,Google Chrome,JavaRuntime8

    DOJO 离线API

    这个API是一个AIR文件,必须先安装 ADOBE AIR 才能用。 http://sttele1.skycn.com/down/AdobeAIRInstaller.zip 详细安装方法,看我的博客 http://hi.baidu.com/w2y0xy0sf5z/blog/item/d524bf8b835d911ac8fc7aef.html

    iphone模拟器电脑版(Desktop iPhone) v3.6 最新版.zip

    1、首先确定电脑安装了Adobe Air软件(点这里可以下载Adobe Air) 2、然后解压缩下载的软件 3、双击文件“DesktopiPhone.air”进行安装 4、软件会自动在桌面上创建快捷方式,点击进入后即可使用。

    Flex Builder 3 帮助文档(已更新,支持Air 1.5)

    是zip压缩格式,解压缩,得到doc文件夹,大部分文件都在langref子目录里,我们需要的是把这些html文件替换为官方已经翻译好的html文件,重新打包就可以了。 2.接下来就是把官方的对应html文件下载过来了。chm文件...

    rebuild_db-1.0-rc1.zip

    X64安装Adobeair必备 rebuild_db-1.0-rc1.zip

    ActionScript 3.0实现PurMVC地图编辑器.src.zip

    1、地图编辑器; 2、purMVC示例,有封装和重写,方便管理; 3、MornUI示例; 4、资源管理; 5、自定义事件,有优化处理,提高效率;...6、Adobe Air的本地资源处理; 7、JSON输入输出解码配置文件;

    Flash课程作业.zip

    Flash课程作业.zip,个人课程做的一个小作品,需要在Flash CS4和以上版本才能打开。感觉Flash已经过时了,即使是Adobe air也挽救AS3.0脚本的颓势。即使过时的技术也要教,大学的课程确实很无奈

Global site tag (gtag.js) - Google Analytics