Okay, that last example wasn't very good, I've always got an Apache
server running on my computer, but that's probably just me. There's a
better example set up here...
http://tinyurl.com/sywqc

Also, it seems Flash isn't picky about zlib compression levels or
anything else, as long as the file is compressed in the zlib format
(http://www.gzip.org/zlib/rfc-zlib.html) it always decompresses in all
my tests so far.

Right now there's several things that could be done with this that I
can think of. Like Claus said, a tool could be created that takes
regular zip files and adds checksum info without damaging
compatibility.

A single file could be compressed into raw zlib data to be
decompressed within Flash, this wouldn't require any extra libraries.

And finally, a custom-made, non-standard format could contain multiple
files which are individually compressed as raw zlib data. I like this
one myself, but I'd like to hear other opinions.

In any case, the imported data could be translated into other things
like sounds, SWF files, images, text, pretty much anything. It could
be compressed more simply and effectively than using, say, Flex's
built-in "embed" feature. The only other way to access external files
without Flex's embed feature is to individually download them. I think
finding some way to effectively use Flash's compression features would
be a major advantage.

On 8/10/06, Max <[EMAIL PROTECTED]> wrote:
Bingo! I've put together a hack that shows this is possible. I tried
doing this with Python, but then I noticed php has the same features
and I'm no good with Python.

Here's how to do it. Make a php file that uses "gzcompress", something
like this...

header('Content-Type: application/octet-stream');
pri​nt gzcompress("this is a test string",9);

Run the page through your browser and save the file somewhere. Then
create a class that opens and uncompress()'s the file. It seriously
works. I'm posting my sample here, I hope email doesn't mangle it.

package {
        import flash.events.Event;
        import flash.net.URLLoader;
        import flash.net.URLLoaderDataFormat;
        import flash.net.URLRequest;
        import flash.utils.ByteArray;
        import flash.events.Event;
        import flash.events.IOErrorEvent;

        public class Testify {
                static private var url:String = "testfile";

                private var urlLoader:URLLoader;

                public function Testify() {
                        trace("Loading "+url);
                        urlLoader = new URLLoader();
                        urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
                        urlLoader.addEventListener(Eve​nt.COMPLETE,onComplete);
                        
urlLoader.addEventListener(IOE​rrorEvent.IO_ERROR,onError);
                        urlLoader.load(new URLRequest(wadUrl));
                }
                private function onComplete(e:Event):void {
                        trace("Loaded");
                        var data:ByteArray = urlLoader.data;
                        urlLoader.data = null;
                        urlLoader.close();
                        urlLoader = null;

                        data.uncompress();

                        data.position = 0;
                        trace(data.readUTFBytes(data.b​ytesAvailable));
                }
                private function onError(e:Event):void {
                        trace("Error");
                }
        }
}

It worked for me. Zlib files are a standard I suppose, any language
with access to zlib could probably pull it off.

Also, Claus, I didn't think of that at all, if you could create a
flash-compatible zip file a wide range of assets could be compressed
into a single file and decompressed within Flash. That's easily the
most intriguing idea I've heard yet.

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to