Packageriaidea.utils.zip
Classpublic class ZipArchive
InheritanceZipArchive Inheritance flash.events.EventDispatcher

使用ZipArchive类,你可以轻松操作各种Zip文件,如.zip/.air/.docx/.xlsx等。



Public Properties
 PropertyDefined by
  length : uint
[read-only] 获取Zip档案里的文件数。
ZipArchive
  name : String
设置和获取Zip档案名称。
ZipArchive
Public Methods
 MethodDefined by
  
ZipArchive(name:String = null)
构造函数,创建一个新的Zip档案。
ZipArchive
  
addFile(file:ZipFile, index:int = -1):ZipFile
添加指定的zip文件到档案。
ZipArchive
  
addFileFromBytes(name:String, data:ByteArray = null, index:int = -1):ZipFile
根据指定的名称和二进制数据添加文件到zip档案。
ZipArchive
  
addFileFromString(name:String, content:String, index:int = -1):ZipFile
根据指定的字符串内容添加文件到zip档案。
ZipArchive
  
getBitmapByName(name:String):void
根据图片文件名称获取Zip档案中的文件,与此方法的事件有ZipEvent.ZIP_CONTENT_LOADED。
ZipArchive
  
getFileAt(index:uint):ZipFile
根据文件位置获取Zip档案中的文件。
ZipArchive
  
getFileByName(name:String):ZipFile
根据文件名获取Zip档案中的文件。
ZipArchive
  
load(request:String):void
加载一个zip档案,与此方法的事件有ProgressEvent.PROGRESS、ZipEvent.ZIP_INIT、ZipEvent.ZIP_FAILED、IOErrorEvent.IO_ERROR。
ZipArchive
  
open(data:ByteArray):Boolean
打开一个二进制流的zip档案。
ZipArchive
  
output(method:uint = 8):ByteArray
输出序列化的Zip档案。
ZipArchive
  
removeFileAt(index:uint):ZipFile
删除Zip档案中的指定位置的文件。
ZipArchive
  
removeFileByName(name:String):ZipFile
删除Zip档案中的指定名称的文件。
ZipArchive
  
toString():String
覆盖默认的toString方法,其中包含ZipArchive对象里的所有ZipFile对象信息。
ZipArchive
Property detail
lengthproperty
length:uint  [read-only]

获取Zip档案里的文件数。

Implementation
    public function get length():uint
nameproperty 
name:String  [read-write]

设置和获取Zip档案名称。

Implementation
    public function get name():String
    public function set name(value:String):void
Constructor detail
ZipArchive()constructor
public function ZipArchive(name:String = null)

构造函数,创建一个新的Zip档案。

Parameters
name:String (default = null)
Method detail
addFile()method
public function addFile(file:ZipFile, index:int = -1):ZipFile

添加指定的zip文件到档案。

Parameters
file:ZipFile — 指定的zip文件。
 
index:int (default = -1) — 指定的位置,默认值为-1,即在末尾添加文件。

Returns
ZipFile
addFileFromBytes()method 
public function addFileFromBytes(name:String, data:ByteArray = null, index:int = -1):ZipFile

根据指定的名称和二进制数据添加文件到zip档案。

Parameters
name:String — 指定文件的名字。
 
data:ByteArray (default = null) — 指定文件的二进制数据。
 
index:int (default = -1) — 指定文件的位置,默认值为-1,即在末尾添加文件。

Returns
ZipFile
addFileFromString()method 
public function addFileFromString(name:String, content:String, index:int = -1):ZipFile

根据指定的字符串内容添加文件到zip档案。

Parameters
name:String — 指定文件的名字。
 
content:String — 指定的字符串内容。
 
index:int (default = -1) — 指定文件的位置,默认值为-1,即在末尾添加文件。

Returns
ZipFile
getBitmapByName()method 
public function getBitmapByName(name:String):void

根据图片文件名称获取Zip档案中的文件,与此方法的事件有ZipEvent.ZIP_CONTENT_LOADED。

Parameters
name:String — 名称。
getFileAt()method 
public function getFileAt(index:uint):ZipFile

根据文件位置获取Zip档案中的文件。

Parameters
index:uint — 位置ID。

Returns
ZipFile
getFileByName()method 
public function getFileByName(name:String):ZipFile

根据文件名获取Zip档案中的文件。

Parameters
name:String — 名称。

Returns
ZipFile
load()method 
public function load(request:String):void

加载一个zip档案,与此方法的事件有ProgressEvent.PROGRESS、ZipEvent.ZIP_INIT、ZipEvent.ZIP_FAILED、IOErrorEvent.IO_ERROR。

Parameters
request:String — 要加载的zip档案地址。
open()method 
public function open(data:ByteArray):Boolean

打开一个二进制流的zip档案。

Parameters
data:ByteArray — 二进制流的zip档案。

Returns
Boolean — 成功打开返回true,否则返回false。
output()method 
public function output(method:uint = 8):ByteArray

输出序列化的Zip档案。

Parameters
method:uint (default = 8) — 指定压缩模式,一般为DEFLATED或STORED。

Returns
ByteArray
removeFileAt()method 
public function removeFileAt(index:uint):ZipFile

删除Zip档案中的指定位置的文件。

Parameters
index:uint — 指定的位置。

Returns
ZipFile
removeFileByName()method 
public function removeFileByName(name:String):ZipFile

删除Zip档案中的指定名称的文件。

Parameters
name:String — 指定文件的名字。

Returns
ZipFile
toString()method 
public override function toString():String

覆盖默认的toString方法,其中包含ZipArchive对象里的所有ZipFile对象信息。

Returns
String — ZipArchive对象的字符串表现形式。