Packagedeng.fzip
Classpublic class FZip
InheritanceFZip Inheritance flash.events.EventDispatcher

Loads and parses ZIP archives.

FZip is able to process, create and modify standard ZIP archives as described in the PKZIP file format documentation.

Limitations:



Public Properties
 PropertyDefined by
  active : Boolean
[read-only] Indicates whether a file is currently being processed or not.
FZip
Public Methods
 MethodDefined by
  
FZip(filenameEncoding:String = "utf-8")
Constructor
FZip
  
addFile(name:String, content:ByteArray = null):FZipFile
Adds a file to the ZIP archive.
FZip
  
addFileAt(index:uint, name:String, content:ByteArray = null):FZipFile
Adds a file to the ZIP archive, at a specified index.
FZip
  
addFileFromString(name:String, content:String, charset:String = "utf-8"):FZipFile
Adds a file from a String to the ZIP archive.
FZip
  
addFileFromStringAt(index:uint, name:String, content:String, charset:String = "utf-8"):FZipFile
Adds a file from a String to the ZIP archive, at a specified index.
FZip
  
close():void
Immediately closes the stream and cancels the download operation.
FZip
  
getFileAt(index:uint):FZipFile
Retrieves a file contained in the ZIP archive, by index.
FZip
  
getFileByName(name:String):FZipFile
Retrieves a file contained in the ZIP archive, by filename.
FZip
  
getFileCount():uint
Gets the number of accessible files in the ZIP archive.
FZip
  
load(request:URLRequest):void
Begins downloading the ZIP archive specified by the request parameter.
FZip
  
loadBytes(bytes:ByteArray):void
Loads a ZIP archive from a ByteArray.
FZip
  
removeFileAt(index:uint):FZipFile
Removes a file at a specified index from the ZIP archive.
FZip
  
serialize(stream:IDataOutput, includeAdler32:Boolean = false):void
Serializes this zip archive into an IDataOutput stream (such as ByteArray or FileStream) according to PKZIP APPNOTE.TXT
FZip
Events
 EventSummaryDefined by
   Dispatched when data has loaded successfully.FZip
   Dispatched when a file contained in a ZIP archive has loaded successfully.FZip
   Dispatched if a call to FZip.load() attempts to access data over HTTP, and the current Flash Player is able to detect and return the status code for the request.FZip
   Dispatched when an input/output error occurs that causes a load operation to fail.FZip
   Dispatched when a load operation starts.FZip
   Dispatched when an error is encountered while parsing a ZIP Archive.FZip
   Dispatched when data is received as the download operation progresses.FZip
   Dispatched if a call to FZip.load() attempts to load data from a server outside the security sandbox.FZip
Property detail
activeproperty
active:Boolean  [read-only]

Indicates whether a file is currently being processed or not.

Implementation
    public function get active():Boolean
Constructor detail
FZip()constructor
public function FZip(filenameEncoding:String = "utf-8")

Constructor

Parameters
filenameEncoding:String (default = "utf-8") — The character encoding used for filenames contained in the zip. If unspecified, unicode ("utf-8") is used. Older zips commonly use encoding "IBM437" (aka "cp437"), while other European countries use "ibm850".

See also

Method detail
addFile()method
public function addFile(name:String, content:ByteArray = null):FZipFile

Adds a file to the ZIP archive.

Parameters
name:String — The filename
 
content:ByteArray (default = null) — The ByteArray containing the uncompressed data (pass null to add a folder)

Returns
FZipFile — A reference to the newly created FZipFile object
addFileAt()method 
public function addFileAt(index:uint, name:String, content:ByteArray = null):FZipFile

Adds a file to the ZIP archive, at a specified index.

Parameters
index:uint — The index
 
name:String — The filename
 
content:ByteArray (default = null) — The ByteArray containing the uncompressed data (pass null to add a folder)

Returns
FZipFile — A reference to the newly created FZipFile object
addFileFromString()method 
public function addFileFromString(name:String, content:String, charset:String = "utf-8"):FZipFile

Adds a file from a String to the ZIP archive.

Parameters
name:String — The filename
 
content:String — The String
 
charset:String (default = "utf-8") — The character set

Returns
FZipFile — A reference to the newly created FZipFile object
addFileFromStringAt()method 
public function addFileFromStringAt(index:uint, name:String, content:String, charset:String = "utf-8"):FZipFile

Adds a file from a String to the ZIP archive, at a specified index.

Parameters
index:uint — The index
 
name:String — The filename
 
content:String — The String
 
charset:String (default = "utf-8") — The character set

Returns
FZipFile — A reference to the newly created FZipFile object
close()method 
public function close():void

Immediately closes the stream and cancels the download operation. Files contained in the ZIP archive being loaded stay accessible through the getFileAt() and getFileByName() methods.

getFileAt()method 
public function getFileAt(index:uint):FZipFile

Retrieves a file contained in the ZIP archive, by index.

Parameters
index:uint — The index of the file to retrieve

Returns
FZipFile — A reference to a FZipFile object
getFileByName()method 
public function getFileByName(name:String):FZipFile

Retrieves a file contained in the ZIP archive, by filename.

Parameters
name:String — The filename of the file to retrieve

Returns
FZipFile — A reference to a FZipFile object
getFileCount()method 
public function getFileCount():uint

Gets the number of accessible files in the ZIP archive.

Returns
uint — The number of files
load()method 
public function load(request:URLRequest):void

Begins downloading the ZIP archive specified by the request parameter.

Parameters
request:URLRequest — A URLRequest object specifying the URL of a ZIP archive to download. If the value of this parameter or the URLRequest.url property of the URLRequest object passed are null, Flash Player throws a null pointer error.
loadBytes()method 
public function loadBytes(bytes:ByteArray):void

Loads a ZIP archive from a ByteArray.

Parameters
bytes:ByteArray — The ByteArray containing the ZIP archive
removeFileAt()method 
public function removeFileAt(index:uint):FZipFile

Removes a file at a specified index from the ZIP archive.

Parameters
index:uint — The index

Returns
FZipFile — A reference to the removed FZipFile object
serialize()method 
public function serialize(stream:IDataOutput, includeAdler32:Boolean = false):void

Serializes this zip archive into an IDataOutput stream (such as ByteArray or FileStream) according to PKZIP APPNOTE.TXT

Parameters
stream:IDataOutput — The stream to serialize the zip file into.
 
includeAdler32:Boolean (default = false) — To decompress compressed files, FZip needs Adler32 checksums to be injected into the zipped files. FZip will do that automatically if includeAdler32 is set to true. Note that if the ZIP contains a lot of files, or big files, the calculation of the checksums may take a while.
Event detail
completeevent 
Event object type: flash.events.Event

Dispatched when data has loaded successfully.

fileLoadedevent  
Event object type: deng.fzip.FZipEvent

Dispatched when a file contained in a ZIP archive has loaded successfully.

httpStatusevent  
Event object type: flash.events.HTTPStatusEvent

Dispatched if a call to FZip.load() attempts to access data over HTTP, and the current Flash Player is able to detect and return the status code for the request. (Some browser environments may not be able to provide this information.) Note that the httpStatus (if any) will be sent before (and in addition to) any complete or error event

ioErrorevent  
Event object type: flash.events.IOErrorEvent

Dispatched when an input/output error occurs that causes a load operation to fail.

openevent  
Event object type: flash.events.Event

Dispatched when a load operation starts.

parseErrorevent  
Event object type: deng.fzip.FZipErrorEvent

Dispatched when an error is encountered while parsing a ZIP Archive.

progressevent  
Event object type: flash.events.ProgressEvent

Dispatched when data is received as the download operation progresses.

securityErrorevent  
Event object type: flash.events.SecurityErrorEvent

Dispatched if a call to FZip.load() attempts to load data from a server outside the security sandbox.