Thursday, January 26, 2012

Reading A Zip File In ActionScript

import nochump.util.zip.ZipEntry;
import nochump.util.zip.ZipFile;

// use the embedded zip
[Embed(source="Archive.zip",mimeType="application/octet-stream")] private static var MyZip:Class;

// create the zip object from the byte array
var zipData:ByteArray = new MyZip() as ByteArray;
var zipFile:ZipFile = new ZipFile(zipData);

// reading the index file from the zip
var indexEntry:ZipEntry = zipFile.getEntry("index.xml");
var indexEntryByte:ByteArray = zipFile.getInput(indexEntry);
var files:XML = new XML(indexEntryByte.readUTFBytes(indexEntryByte.length));

No comments:

Post a Comment