示例代码如下:

Code
package
{
import flash.display.Sprite;
import flash.utils.ByteArray;
import flash.filesystem.*;
import deng.fzip.FZip;
public class Main extends Sprite{
public function Main(){
init();
}
private function init():void{
// Create text file contents
var textBA:ByteArray = new ByteArray();
textBA.writeUTFBytes("Hello World!");
//
//Create xml file contents
var xmlStr:String = '<?xml version="1.0" encoding="UTF-8" ?><info><url>http://www.baidu.com/</url><pic>girl.jpg</pic></info>';
var xmlBA:ByteArray = new ByteArray();
xmlBA.writeUTFBytes( xmlStr );
// Create ZIP archive and add file
var zip:FZip = new FZip();
//zip.addFile("hello.txt", null, ba);
zip.addFile("hello.txt", textBA);
//add xml file
zip.addFile("info.xml", xmlBA);
// Serialize ZIP into a new file
// (we use the Adobe AIR specific class FileStream here,
// but you can as well use ByteArray or anything that
// implements IDataOutput)
//var file:File = File.applicationStorageDirectory;
var file:File = File.desktopDirectory;
file = file.resolvePath("hello.zip");
var stream:FileStream = new FileStream();
stream.open(file, FileMode.WRITE);
zip.serialize(stream);
stream.close();
}
}
}
相关连接:http://wahlers.com.br/claus/blog/fzip-alpha-release-create-and-modify-zip-archives/