Home > flex > Loading zip files in AS3

Loading zip files in AS3

Working on a project where I need to load and unzip files in Flash I stumbled on some pretty useful libraries.

The first is FZip which can load modify and create zip files in Flash.
Perks: FZip parses ZIP archives progressively, allowing access to contained files while the archive is loading.
Detractors: If not used in an AIR environment which provides a low level deflate method it can’t unzip compressed zip files without your manually injecting an Adler32 Checksum to the file ahead of time. They provide convenient Python and Java code to unobtrusively inject Adler32 checksums in your zip files.

The other is nochump.com’s AS3 Zip Library.
Perks: Can unzip files without the need of injecting Adler32 Checksums ahead of time.
Detractors: Slow as balls.

For a project I’m working on where I have a ton of zip files to parse I find myself using the first and falling back to the latter if the Adler32 Checksum is not found. I’m far from a command line exert but here is a handy line you can place in terminal to recursively scan the working directory for every zip file and add Adler32 checksums via FZip’s handly fzip-prepare.py python script (note that it is only checking for zip files above 1MB):
find . -size +1M -iname “*.zip” | sed -e ‘s/.*/”&”/’ | xargs -I {} python /fzip-prepare.py {} -L1

Categories: flex Tags:
  1. Lara
    December 9th, 2010 at 09:09 | #1

    Hi,
    i am not sure, wether this is the right place for these questions, but maybe.

    Have been trying quite a while to find examples for using FZip, especially to use it with an embedded zip, as the author mentions in his readme (“liesmich.rtf”) file.

    I need to build a download version of an AS3-animation (Flashdevelop) with a lot of assets and hope to address them by filename instead of embedding each of them separately.

    First problem: After the embed:
    [Embed(source = 'resources.zip', mimeType = 'application/octet-stream')]
    I shall “Access the resources using FZip” but how do I connect the embedded zip with a FZip instance to use the FZip-library on.

    Second problem:
    You write about using the python script on a lot of files. I would be happy to know how to use it on a single zip. Or how to use the java files. I just need to get a zip working with FZip in the Flashplayer.

  1. October 5th, 2011 at 14:45 | #1