/* * Copyright 2008 tarotarorg * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package { import flash.display.Sprite; import flash.events.IOErrorEvent; import flash.net.URLLoaderDataFormat; import flash.net.URLRequest; import flash.text.TextField; import flash.utils.ByteArray; import flash.events.Event; import org.tarotaro.flash.pv3d.ZipLoader; [SWF(width="640", height="480", backgroundColor="#ffffff")] /** * ZipLoaderの使用例 * @see org.tarotro.flash.pv3d.ZipLoader * @author 太郎 */ public class ZipLoaderSample extends Sprite { public function ZipLoaderSample() { var zipLoader:ZipLoader = new ZipLoader(); zipLoader.addEventListener(Event.COMPLETE, zipLoadComplete); zipLoader.addEventListener(IOErrorEvent.IO_ERROR, function(e:IOErrorEvent):void { trace("IOエラー:", e); }); zipLoader.dataFormat = URLLoaderDataFormat.TEXT; zipLoader.load(new URLRequest("./samples/outer.zip://foo.zip://bar/sample.txt")); } private function zipLoadComplete(e:Event):void { trace("zipファイルのロード完了"); var data:ByteArray = e.target.data; var tf:TextField = new TextField(); tf.width = 640; tf.height = 480; tf.appendText(data.toString() + "\n"); tf.appendText(e.target.dataFormat); addChild(tf); } } }