as3: unpack zip = faster than loading single images?
by using external libraries you can also unpack a preloaded zip inside the swf.
but i开发者_如何学Gos that method faster than preloading one file ?
If you have a large number of images, it may be better to package them as a zip, packing efficiency will depend on the type of images you are using.
That said, there is often little gain in file size when zipping png or jpg images. If there is a good gain in file size, then the downloading time can be offset against the unzipping time.
So the easy answer is, maybe: compare file size of the zip vs the combined images, then profile an average unpack time. If you can get a fast unpack + file size gain, then it's worthwhile.
Don't forget to factor in the overhead of the unzip library in the SWF file.
Yes. I've done some basic benchmarks, and implemented into a few projects, the answer is yes. Images are already compressed, so the performance gain has nothing to do with file size. Actually the zip might even be larger in the end. The gain is in the number of HTTP requests that need to be made. Every http request evolves a fair bit of hand shaking, reducing 50 requests to one shows a major speed difference, one that grows as the number of images increases.
With text files, the difference is far greater, as you see compression too. One image by itself sees no benefit, only groups.
Sorry for typos, I'm on my phone.
Edit: I'll add the best solution seems to be storing bitmaps in a swf and loading that. Flash does some amazing compression, especially with PNGs.
EDIT 2: I've put up some simple tests as a demo here.
精彩评论