Because a zip file permits a number of compression algorithms so a ZIP file contains one or more files. FZip is a cute little Actionscript 3 class library, it parses ZIP archives progressively, allowing access to contained files while the archive is loading(@see Actionscript 3 class zip library–FZip).
Now we will introduce an other actionscript zip library: ASZip. You can generate ZIP files from ActionScript 3 with ASZip. ASZip uses the native gzip (Deflate) compression from the flash.utils.Bytearray.compress() method. More compression algorithms will be added in the future. ASZip has simple interface to add different types of files and directories.
The following is a simple sample to generate a text file and PNG file to a zip file:
- // create the Zip file, first param : compression method
- var myZip:ASZip = new ASZip (CompressionMethod.GZIP);
- // create a flash.display.BitmapData
- var myStevie:Stevie = new Stevie (0, 0);
- // encode it as a PNG
- var bytes:ByteArray = PNGEnc.encode (myStevie);
- // create a text stream
- var txt:ByteArray = new ByteArray();
- // write some text into it
- txt.writeUTFBytes("Hello there !!");
- // add a pics folder
- myZip.addDirectory ("pics/");
- // then a text folder
- myZip.addDirectory ("text/");
- // pass the PNG stream and specify a file name and location
- myZip.addFile (bytes, "pics/stevie.png");
- // pass the text stream and specify a file name and location
- myZip.addFile (txt, "text/story.txt");
- // add a comment
- myZip.addComment ("A comment !");
- // generate final Zip file
- var myZipFile:ByteArray = myZip.saveZIP ( Method.LOCAL );
You can download the source from: http://code.google.com/p/aszip/downloads/list
For help, advice, tips and tricks, challenges, feel free to visit our
or Submit your good resource to share.
Reminder: Unless stated otherwise, all resources published on this site are NOT for commercial use. To use any resource from this site for commercial purposes, please contact the author.

