原文链接:AS3的一些压缩解压缩类库(AS3 ZIP、AS3 GZIP等等)

在现在开发的游戏中,由于战斗数据比较大,所以尝试对战斗数据进行压缩,然后输出到客户端flash端再解压。

Google到一篇文章,对照翻译工具翻译一下 :)

在我的一些项目中,经常需要对数据做一些转换操作,所以积累一些很有意思的用于数据压缩/解压缩的第三方类库。

当然ByteArray类本身就带了数据压缩和解压缩的方法,可以用在flash player使用zlib算法和AIR程序使用多种算法。在FLASH跟PHP作为后台的编程中,我后来选择了ByteArray的compress方法来做zlib算法的压缩,用这个方法用的比较顺手,而且很快。

下面是一些第三方的类库地址以及介绍:

  • AS3 Zip: AS 3 下用来读取和写入zip文件的类库
  • FZip: FZip 是一个用于AS 3 下读取、创建、修改zip压缩包的类库
  • ASZip: AS 3 用于创建zip文件的类库
  • LZMA Encoder: AS3下使用LZMA算法压缩数据的类库.
  • LZMA Decoder: 跟上面类库对应的用于LZMA算法解压缩数据.
  • AsCompress: AS3下 GZIP压缩和解压缩类库,好像需要SDK版本在4.x以上,flash cs3下不可用。
  • Gzip for HTTPService/URLLoader: 给你的 Flex/AIR HTTPService/URLLoader增加gzip支持
  • airxzip: AIR的zip类库

如果你还知道更多的类库或者其他好东东,欢迎告知!

翻译自:http://blog.yoz.sk/2011/01/quick-tip-compression-in-flash/

While working on one of my projects where I needed compression for transfered data, I hit some very interesting compression libraries. Also the ByteArray class contains compress method, using zlib algorithm in flash player or multiple algorithms in AIR. At the end I decided to useByteArray.compress() method for encoding vs. PHP gzuncompress for decoding, what works correctly, fast and smooth.

Here is a list of 3rd party compression libraries and other good stuff:

  • AS3 Zip: ActionScript 3 based library for reading and writing zip files
  • FZip: FZip is an Actionscript 3 class library to load, modify and create standard ZIP archives.
  • ASZip: ActionScript 3 library to generate ZIP files
  • LZMA Encoder: AS3 class to compress data using LZMA algorithm.
  • LZMA Decoder: A part of the apparat framework.
  • GZIP: ActionScript GZIP compression library
  • Gzip for HTTPService/URLLoader: Adding Gzip support for Flex/AIR HTTPService/URLLoader
  • airxzip: Zip library for ActionScript3 on AIR

If you know some more, please let me know.

===============================================================================
附一个自己平时经常用的类库ZipArchive,以下是主页及帮助文档:
http://code.google.com/p/as3-ziparchive/
http://www.riaidea.com/as3/zip/asdoc/riaidea/utils/zip/ZipArchive.html

ZipArchive是一个Zip档案处理类,可读写各种zip格式文件。如zip/swc/air/docx/xlsx等。


Features

  • 轻松创建或加载一个zip档案;
  • 多种方式读取和删除zip档案中的文件;
  • 支持中文文件名;
  • 非常容易序列化一个zip档案,如有AIR、PHP等的支持下就可以把生成的zip档案保存在本地或服务器上。

Usage

package  
{        
        import flash.display.*; 
        import flash.events.*; 
        import flash.utils.*;    
        import com.riaidea.utils.zip.*; 
         
         
        [SWF(width =500, height =400, frameRate =24, backgroundColor =0xFFFFFF)] 
        publicclassExampleextendsSprite  
        {                
                privatevar zip:ZipArchive;              
                privatevar swc:ZipArchive;              
                 
                publicfunctionExample()  
                { 
                        testZip(); 
                        testSWC(); 
                } 
                 
                privatefunction testZip():void 
                { 
                        zip =newZipArchive(); 
                        handleEvents(zip,true); 
                        zip.load("assets/test.zip"); 
                } 
                 
                privatefunction processZip():void 
                { 
                        //显示zip文件的详细文件信息 
                        trace(zip.toComplexString()); 
                         
                        //读取zip中的xml文件 
                        var xmlFile:ZipFile= zip.getFileByName("sample.xml"); 
                        var xml:XML =new XML(xmlFile.data); 
                        trace(xml); 
                         
                        //复制zip中的"girl.jpg"为"张曼玉.jpg" 
                        var zmy:ZipFile= zip.getFileByName("girl.jpg"); 
                        zip.addFileFromBytes("张曼玉.jpg", zmy.data); 
                         
                        //异步加载并显示zip中的新生成的图片"张曼玉.jpg" 
                        zip.getAsyncDisplayObject("张曼玉.jpg",  
                        function(img:DisplayObject):void  
                        {  
                                addChild(img); 
                                img.x =10; 
                                img.y =10; 
                        }); 
                         
                        //删除zip中的文件"girl.jpg" 
                        zip.removeFileByName("girl.jpg"); 
                         
                        //异步加载并显示zip中的SWF文件"loading.swf" 
                        zip.getAsyncDisplayObject("loading.swf",  
                        function(swf:DisplayObject):void  
                        {  
                                addChild(swf); 
                                swf.x =150; 
                                swf.y =10; 
                        }); 
                         
                        //根据字符串内容创建一个新的txt文件 
                        var txtContent:String="这是一个测试文本文件"; 
                        zip.addFileFromString("empty_dir/test.txt", txtContent); 
                         
                        //显示修改后的zip文件信息 
                        trace(zip.toComplexString()); 
                } 
                 
                privatefunction testSWC():void 
                { 
                        swc =newZipArchive(); 
                        handleEvents(swc,true); 
                        swc.load("assets/puremvc.swc"); 
                } 
                 
                privatefunction processSWC():void 
                { 
                        //显示swc文件的详细文件信息 
                        trace(swc.toComplexString()); 
                         
                        //读取swc文件中的所有类定义 
                        var catalog:ZipFile= swc.getFileByName("catalog.xml"); 
                        var catalogXML:XML = XML(catalog.data); 
                        trace(catalogXML..(catalogXML.namespace())::def); 
                } 
                 
                privatefunction handleEvents(zip:ZipArchive, add:Boolean):void 
                { 
                        if(add) 
                        { 
                                zip.addEventListener(ZipEvent.PROGRESS, onProgress); 
                                zip.addEventListener(ZipEvent.LOADED, onLoaded); 
                                zip.addEventListener(ZipEvent.INIT, onInit); 
                                zip.addEventListener(ZipEvent.ERROR, onError); 
                        }else 
                        { 
                                zip.removeEventListener(ZipEvent.PROGRESS, onProgress); 
                                zip.removeEventListener(ZipEvent.LOADED, onLoaded); 
                                zip.removeEventListener(ZipEvent.INIT, onInit); 
                                zip.removeEventListener(ZipEvent.ERROR, onError); 
                        } 
                } 
                 
                privatefunction onInit(evt:ZipEvent):void  
                { 
                        handleEvents(evt.target asZipArchive,false);                   
                        switch(evt.target) 
                        { 
                                case zip: processZip();break; 
                                case swc: processSWC();break; 
                        } 
                }                
                 
                privatefunction onProgress(evt:ZipEvent):void  
                { 
                        //trace(evt.message.bytesLoaded, evt.message.bytesTotal); 
                } 
                 
                privatefunction onLoaded(evt:ZipEvent):void  
                { 
                        //trace(evt); 
                } 
                 
                privatefunction onError(evt:ZipEvent):void  
                { 
                        //trace(evt); 
                } 
        } 
}

AS3的一些压缩解压缩类库(AS3 ZIP、AS3 GZIP等等)相关推荐

  1. Linux运维:常用的压缩解压缩命令(zip、tar)

    文章目录 压缩类型 zip类型 1.zip压缩 2.unzip解压缩 tar类型 1..tar压缩和解压 2..tar.gz压缩和解压 3..tar.bz2压缩和解压 4..tar.Z压缩和解压 5. ...

  2. Kali下压缩解压缩命令大全zip、gz、tar、tar.gz、bz2、tar.bz2、bz、tar.bz、Z、tar.Z、taz、tar.tgz、zip、rar、lha

    目录 解压缩 tar gz tar.gz bz2 tar.bz2 bz tar.bz Z tar.Z tgz tar.tgz zip rar lha 熟知 ZIP tar tar.gz tar.bz2 ...

  3. Linux的压缩/解压缩文件命令 zip 和 tar

    Linux的压缩/解压缩命令详解及实例 压缩服务器上当前目录的内容为xxx.zip文件 zip -r xxx.zip ./* 解压zip文件到当前目录 unzip filename.zip 另:有些服 ...

  4. Java实现文件压缩与解压[zip格式,gzip格式]

    原文:http://www.cnblogs.com/visec479/p/4112881.html#3069573 Java实现ZIP的解压与压缩功能基本都是使用了Java的多肽和递归技术,可以对单个 ...

  5. java gzip 解压文件_Java实现文件压缩与解压[zip格式,gzip格式]

    原文:http://www.cnblogs.com/visec479/p/4112881.html#3069573 Java实现ZIP的解压与压缩功能基本都是使用了Java的多肽和递归技术,可以对单个 ...

  6. linux压缩和解压缩命令tar,zip,gzip

    Linux上有很多解压缩文件的命令.其中最新和最有效的是xz,但他们都有节省磁盘空间和保存文件供以后使用的优点.在这篇文章中,我们比较了解压缩命令并指出了显著的区别. 1.tar 语法: tar [o ...

  7. java压缩解压缩rar、zip文件

    来源https://www.open-open.com/lib/view/open1363592512046.html 被zip 折腾的要死,特意记录一下来,以后防翻车 package cn.com. ...

  8. mac 命令行 解压7z文件_命令行压缩解压缩一 7z

    命令行压缩解压缩一 7z 1) 简介 7z,全称7-Zip, 是一款开源软件.是目前公认的压缩比例最大的压缩解压缩软件. 主页:http://www.7-zip.org/ 中文主页:http://7z ...

  9. as3压缩解压缩的第三方包及实现DEMO

    用到as3 解压缩zip文件.上网找了都是只能解压缩生成bytearray,而不是直接生成文件或目录结构.所以只能自己根据bytearray手动实现.. <?xml version=" ...

最新文章

  1. 聊聊服务治理中的路由设计
  2. Android Studio开发RecyclerView遇到的各种问题以及解决(一)
  3. TensorFlow 变量共享,命名空间
  4. Deep Learning回顾之LeNet、AlexNet、GoogLeNet、VGG、ResNet
  5. 百度地图手绘线坐标获取
  6. Linux 文件系统初探
  7. 【建议收藏】面试官贼喜欢问的 32+ vue 修饰符,你掌握几种啦?
  8. 互联网晚报 | 12月11日 星期六 | 极兔正式入股百世快递;全球首颗云原生卫星诞生;紫光集团重组战略投资者确定...
  9. 中国企业借东博会“走出去”将打造马来西亚首个智慧城市
  10. Archlinux安裝指南(uefi+gpt)
  11. “暴风一号”学习日记(一)
  12. kali linux嗅探图片_kali linux 密码嗅探工具 Dsniff 详解
  13. 微信小程序怎么做【零基础教程附源码】
  14. 国内外无线传感器网络专利分析
  15. SSM框架整合仿QQ空间
  16. 计算机中存储的数据类型
  17. citrix vdi 服务器性能要求,Citrix测试VDI的最佳hypervisor
  18. 在线博客系统——文章详情(redis incr自增实现增加阅读数和评论数)
  19. new一个对象的时候发生了什么?
  20. 访谈编码怎么做_【建模28】胜任力构建的技能——编码

热门文章

  1. python爬取豆瓣电影排行榜_爬取豆瓣电影排名的代码以及思路
  2. JavaScript:执行机制
  3. cv mat保存图片_EmguCV创建/保存图片
  4. Vue的mergeOptions函数分析-下
  5. 一个故事告诉你什么是消息队列
  6. log4cpp 用法
  7. mime.types
  8. springboot启动命令linux,springboot项目命linux环境下命令启动
  9. 【李宏毅2020 ML/DL】P76 Generative Adversarial Network | Unsupervised Conditional Generation
  10. Java - 泛型 ( Generic )