ActionScript GZIP compression library

This is an ActionScript library for encoding (compressing and uncompressing) files using the GZIP compressed file format. The source code for the ActionScript GZIP encoding library is hosted on Google Code; the code is available under the MIT license.

Note: version .2 and previous were licensed under the Mozilla Public License, v. 1.1.

Where it’s been used:

You can leave a comment, or trackback from your own site.

  • Pingback: Danny Patterson

  • Pingback: Lynch Consulting Blog

  • Pingback: Yahoo! Developer Network Blog

  • Pingback: Adobe - Developer Center : Compressing files and data

  • Pingback: Extending the Flex HTTP Service to Support Binary Data

  • Alex

    Hi Paul,

    I was pretty excited to find your GZIP library and was going to use it in my project. But then I discovered that it doesn’t work with Flex. Flex’s implementation of ByteArray.compress() is different than AIR’s and supports only default zlib compression. Any idea why are they different? Will Flex ever support gzip?

    Thanks,
    Alex

  • http://probertson.com/ Paul

    @Alex:

    Just to clarify, the library does work with Flex (I’ve only ever used it with Flex) as long as your Flex app runs in AIR. However, the library doesn’t work in Flash Player 9, so it doesn’t work in a Flex app that runs in the browser (or a non-Flex app that runs in the browser, for that matter).

    The additional functionality (compression using the Deflate algorithm rather than zlib) was added in AIR — as you’ve noted, Flash Player only supports zlib.

    The good news is that the functionality that was added in AIR has been rolled back into Flash Player for the next release (Flash Player “Astro”), which is currently available as a public beta. I haven’t updated the library to support that new functionality, obviously, but I plan to do so soon.

  • Pingback: „ÅØ„Ŷ„Å™„Éñ„ÉÉ„ÇØ„Éû„ɺ„ÇØ - FZip - codeazur brasil lab

  • akhil

    this library is working with desktop AIR application. But i want to use this library in web application flex. how can i do this

    thank you

  • http://probertson.com Paul

    @akhil:
    Others have also commented on this, above. As I replied, it is theoretically possible to use the library in a Flash Player (browser) application now that the raw DEFLATE compression is supported in Flash Player. However, the refactoring work to support it turned out to be more complex than I thought so I haven’t had a chance to finish it up.

    Obviously there is interest in it, so I’ll try to take a look at it soon and see what I can do to get it working.

  • http://probertson.com/ Paul Robertson

    For everyone who’s asked (and I’m surprised how many have), I’ve got a beta (barely tested) version of the library with support for Flash Player-only projects (no AIR dependencies). See the full post for details.

  • http://www.learnosity.com/techblog Mark Lynch

    Hi Paul,

    Thanks for the great piece of code - I’ve taken your new version and used it with Anirudh’s code (with some minor modification) to make a drop in replacement for HTTPService which will handle both gzip’d and non gzip’d content.

    http://www.learnosity.com/techblog/index.cfm/2009/3/19/More-of-AIR-Gzip-compression

    Great work.
    Thanks,
    Mark

  • http://snakemedia.net Joe Corner-Reeve

    Hello guys,
    Is your compression function in actionscript 3?

    Wow! I think because we need high-level compression by function like WinRar, 7z or kgb compressing functions. How do i know about currect encoder by rar, 7z or kgb compressed files?
    Where do i find encodes from internet?

    I have problem of adobe air while my sample file will compressing onto compressed file. But adobe air application was killed by debug while compression process lose that long time.. :(

    I need processbar on panel like WinRar with process panel while compressor will to be final created compressed files?

    Thank you! Ragards, Joe Corne-Reeve

  • http://probertson.com/ Paul Robertson

    @Joe:
    The compression is built into AIR/Flash Player, so it runs in native code, not in ActionScript. Other compression formats such as the ones you mention would either need to be included in the player or rewritten in ActionScript.

    Unfortunately, the compression and decompression run synchronously in Flash Player/AIR, so there’s no way to get progress notifications (or even run any other code) while they’re running.

  • k.chandra shekar

    hi paul

    I am trying to compress the files in flex app using flash player 10 but it is not working in fp10 give me exact solution how to compress files in flex web application development not in the air
    i neede so how to do pls help me the ways
    bye

  • Gregor Rot

    For flash player 10 that supports gzip comp/decomp, the only thing that needed to be changed in the code is:

    data.compress(…) -> data.inflate();
    data.uncompress(…) -> data.deflate();

    Gregor

  • Pingback: Flex to REST w/ GZip return | Flex Developer forums

  • Matias

    What about split compressed files?

    ie:
    encoder.compressToFile(source, destination, limitPerFile);

    Can I do this?

    Any idea?

  • http://probertson.com/ Paul Robertson

    Matias,
    The library doesn’t support “split” compressed files. I based the library on the GZIP spec, and it doesn’t say anything about a standard way of splitting files (unless I missed it or they’ve added it in since then). If you know of a standard way of doing it, or you’ve seen another GZIP implementation that provides that support, let me know and I can try to research it and implement it. Otherwise, it doesn’t seem to make sense to implement that as a feature since other GZIP implementations wouldn’t be able to understand how to decompress the files.

  • Pingback: Adobe AIR SOAP WebService Compression « Norvinet's Blog

  • Ross R

    I am trying to implement this to compress an XML String which will be sent to JS via ExternalInterface, and then posted to a C# page.

    It isn’t working at the moment, because I don’t seem to be able to get a String representation of the compressed ByteArray. For some reason, the JS fires off an error as soon as I pass the byteArray string to it “unterminated string element” or some such.

    Any ideas how I can make this work for my purposes?

  • http://probertson.com/ Paul Robertson

    Hi Ross,

    You can’t directly get a string representation of a ByteArray. (Well, you can try, but chances are some of the characters will be outside the normal character range.) One common way of string-encoding binary data is to convert the ByteArray to a Base64-encoded string. You would then need to decode it to binary again on your server.

    Flex SDK includes a Base64Encoder class that will do the Base64 encoding for you. You just pass the ByteArray to your Base64Encoder and then call toString() to get the Base64 string.

  • Pingback: HOW TO COMPRESS FILES AT THE CLIENT END IN ADOBE AIR : 93920

  • Pingback: Carlos Bueno: A Dismal Guide to Bandwidth

  • Pingback: gzip encoding in Adobe AIR

  • Pingback: Adding Gzip support for Flex/AIR HTTPService / URLLoader | Skinkers

  • Adnan

    Most of the links are broken now. How can I access the data

  • http://probertson.com/ Paul Robertson

    @Adnan,
    Thanks for letting me know about the broken links. I’ve fixed the ones in the post body.

    If you have other questions about how to use the library you may want to start with the Adobe Developer Center article (now that I fixed the link =), and feel free to ask if you have other questions.

  • Pingback: Writing Flex 3 ByteArray deflate algorithm - Stack Overflow

  • Pingback: Quick Tip: Compression in Flash at Jozef Ch???•ka's blog

  • Pete

    Is there no documentation for this?

  • Pete

    Never mind, I figured out how to use it.

Articles by Type

Articles by Topic

Random Reading

Currently...

Adobe MAX 2011 Speaker H. Paul Robertson: Adobe Community Professional

Subscribe