在AS3.0中使用压缩文件来管理资源,可以方便管理和减少资源总大小。
private function loadAssets():void{
var zip:FZip = new FZip();
zip.load(new URLRequest("classics.zip");
zip.addEventListener(Event.COMPLETE, unZip);
}
private function unZip(event:Event):void
{
var dic:Dictionary = new Dictionary();
var zip:FZip = event.currentTarget as FZip;
var fc:int = zip.getFileCount();
for(var i:int = 0;i<fc; i++)
{
var zipfile:FZipFile = zip.getFileAt(i);
var key:String = zipfile.filename.substr(0, zipfile.filename.length - 4);
dic["/" + key] = zipfile.content;
}
zip.close();
//handle data
.....
}