
ActionScriptの標準ライブラリではZIPファイルの解凍機能は提供されていないので、自分で作るか、他人様が作成されて公開されているものを使うしかない。
勉強がてら作ってみるのは面白いのだが、今回の仕事はそういうライブラリが存在していることを前提に作業工数を見積もっているので、
FZip - http://codeazur.com.br/lab/fzip/
という、フリーのライブラリを使ってみた。(商用利用も問題なさげ)
日本語のドキュメントがほとんど存在していないため、英語のサンプルソースを見てどうにかするしかなかったので少し時間がかかったが、例えば任意のZIPファイルを解凍するだけなら以下のようなソースになる。
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" 
    initialize="initProc()"
    layout="absolute" width="480" height="208">
    <mx:Label x="183" y="18" text="ZIP解凍 テスト" fontSize="18" id="Title"/>
    <mx:TextArea x="23" y="54" width="428" height="122" id="Message"/>
    <mx:Script>
    <![CDATA[
    import deng.fzip.FZip;    // ZIP操作ライブラリ
    import flash.events.*;  
    import flash.net.URLRequest; 
    public var Fzip:FZip;
    public var ZipFileName:String    = "data/cont/ds.zip";
    public var ZipDirName:String    = "data/cont/ds/";
    private function initProc():void {
        Fzip = new FZip(); 
        var request:URLRequest = new URLRequest();
        var file:File = File.applicationStorageDirectory.resolvePath(ZipFileName);
        request.url = file.nativePath;
        Message.text    += "FN=" + file.nativePath + "\n";
        Fzip.addEventListener(Event.COMPLETE, loadComplete);
        Fzip.addEventListener(IOErrorEvent.IO_ERROR, onIOError); 
        Fzip.load(request);
 
    }
 
    public function loadComplete(evt:Event):void {
        var file:File;
        var stream:FileStream;
        for(var i:int=0; i < Fzip.getFileCount(); i++){
            Message.text    += Fzip.getFileAt(i).filename + "\n";
            file = File.applicationStorageDirectory.resolvePath(ZipDirName + Fzip.getFileAt(i).filename);        
            stream    = new FileStream();
            try {
                stream.open(file,FileMode.WRITE);
                stream.writeBytes(Fzip.getFileAt(i).content);
                Message.text    += "File Output Success. " + file.nativePath + "\n";
            }
            catch(error:IOError) {
                Message.text    += "File Output Error.\n";
            }
            finally {
                stream.close();
            }
        }
    }
    private function onIOError(evt:IOErrorEvent):void {
        Message.text    += "There was an IO Error.\n";
    }
    ]]>
    </mx:Script>
</mx:WindowedApplication>
これで、ばっりち applicationStorageDirectory 以下の data/cont/ds/ ディレクトリ以下にファイルが展開される。
FileStream は、子ディレクトリが存在していなければ勝手に掘ってくれるので楽だ。