Yes, Virginia, There is Compression in Flash
Posted in "General" at 3:27 pm on June 30, 2009 by Alaric Cole | 1 commentI’m in the process of developing a new hybrid component–a component which utilizes the Flash Player but via a JavaScript API–for YUI. This new component will take advantage of Flash’s native SharedObject functionality to store local data in a larger amount than is typically allowed by a cookie. By default this storage is up to 100kb. However, I found a way to store nearly half a megabyte in this space.
No, I didn’t have to request the user to allow 512kb of storage on their machine. And there was no magic or hackery involved. That’s because the space I took up on the hard drive was less than 100kb. I just took advantage of a little known feature in the Flash Player, allowing compression of data.
This feature is quietly tucked away inside of the ByteArray class–ByteArray.compress() and ByteArray.decompress().
Taking what was a half meg of JSON data over-the-wire and putting it into a SharedObject (which stores in binary) resulted in a huge savings already, about 60%. But compressing that data before storage resulted in a total of 80% savings.
I’ve still got some performance testing to do, as for all compression one must sacrifice processor cycles for storage space. But I feel pretty confident this will remain in the release version. So, either take this idea and run with it, or wait a bit for the next YUI release.
By the way, I also recently posted an article on the YUI Blog entitled Flash SOL: Persistent Data with Local SharedObjects. Thought I’d share it with you all, if you didn’t see it.
Share: on Yahoo! My Web | on del.icio.us | digg it! | reddit!
1 Comment »
RSS feed for comments on this post. TrackBack URI
Leave a comment

Copyright © 2007 Yahoo! Inc. All rights reserved. Privacy Policy - Terms of Service
Powered by WordPress on Yahoo! Web Hosting.
How does this compare to a gzipped JSON via AJAX?
I’ve seen ratios of 10:1 in gzipped JSON, but to be certain we should use the same sample with both methods.
Also: Is the browser faster decompressing than flash?
In terms of persistence this is obviously better, but the browser cache can store JSON also, and that is enough for my case.
I’ll be happy to help you build some test cases.
Comment by Martin — July 1, 2009 #