Reading Zip files with Actionscript 3
Posted: September 24th, 2007 | Author: Tiago Bilou | Filed under: Actionscript3, Code, Tutorial | 6 Comments »Last week, while developing an actionscript application, we had the need to read files stored inside a zip file. Our first approach was to use Zinc to deflate the zip file into a temporary directory.
Because some problems arouse with ZINC I took sometime to read about this AS3 Zip Library As it turns out it does a great job and reading and building zip files and it's really easy to use. Make sure you download and install the Library.
After playing around with this Library for a while I wanted to display some images I had inside the zip file. The issue was how to convert a ByteArry into a BitmapData. It took me a while to figure it out , but as it turns out it's really easy.
How to implement this fzip i am new to as not sure how to set it up if u can show me a woking example in a mxml it ll be great. going nuts setting up fzip… fairly new to as and not sure how to use classes and stuff. pls help
I’m using this library in air javascript application, so when i try to use this code i get the following error:
TypeError: Value undefined is not a constructor. Cannot be used with new.
My code is:
var urlStream = new air.URLStream();
urlStream.addEventListener(air.Event.COMPLETE, _completeHandler);
urlStream.load( new air.URLRequest( url ) );
function _completeHandler(event){
air.Introspector.Console.log(event);
var datastream = air.URLStream(event.target);
var zipFile = new air.ZipFile(datastream);
for(var i = 0; i <= zipFile.entries.length; i++) {
var entry = zipFile.entries[i];
air.Introspector.Console.log(entry.name);
}
}
Sorry, i’m new in air development with javascript.
I replace:
var zipFile = new air.ZipFile(datastream);
===================
For this:
var zipFile = new window.runtime.nochump.util.zip.ZipFile(datastream);
Its useful! nice thanx for the code
Great Job. My problem is resolved. I’m able to unzip the xml file and get the data. thank you so much.
Could you use this library in a web based swf file to have the swf read all of the resources it needs (images,videos,xml) from a zip file? … better yet, could you implement a generic swf that when passed a zip file read an xml specification file (manifest.xml?) for which resource in the zip file is the actually flash object to load and run?