下面是一段在Adobe air中解压zip的代码,是从一个老外的博客中转来的:
Today, I'm going to show you how you can use the nochump library to extract zip files with Adobe AIR.
The ZipFile class constructor takes an IDataStream object as the parameter.Here you can use a ByteArray or a FileStream object which contains the data of the zip file. The entries property of the ZipFile object contains all the files in the archive as ZipEntry objects. Here the directory itself(excluding the files inside it) also counts as a ZipEntry object, so make sure to check using the isDirectory property of the ZipEntry object. Finally get the data of a single file using zipFile.getInput() method.
Here's the code :
import flash.filesystem.*;
import flash.net.FileFilter;
import nochump.util.zip.*;
private var zipInput:File = new File();
private var zipOutput:File = new File();
private var zipFile:ZipFile;
private function loadZIP():void
{
var filter:FileFilter = new FileFilter("ZIP","*.zip");
zipInput.browseForOpen("Open ZIP file",[filter]);
zipInput.addEventListener(Event.SELECT, onSelect);
}
private function onSelect(e:Event):void
{
var stream:FileStream = new FileStream();
stream.open(zipInput,FileMode.READ);
zipFile = new ZipFile(stream);
extract.enabled = true;
}
private function extractZIP():void
{
zipOutput.browseForDirectory("Select Directory for extract");
zipOutput.addEventListener(Event.SELECT, onDirSelect);
}
private function onDirSelect(e:Event):void
{
for(var i:uint = 0; i < zipFile.entries.length; i++)
{
var zipEntry:ZipEntry = zipFile.entries[i] as ZipEntry;
// The class considers the folder itself (without the contents) as a ZipEntry.
// So the code creates the subdirectories as expected.
if(!zipEntry.isDirectory())
{
var targetDir:File = e.target as File;
var entryFile:File = new File();
entryFile = targetDir.resolvePath(zipEntry.name);
var entry:FileStream = new FileStream();
entry.open(entryFile, FileMode.WRITE);
entry.writeBytes(zipFile.getInput(zipEntry));
entry.close();
}
}
}
You can download the project archive here. Happy experimenting
from: http://pradeek.blogspot.com/2009/05/extracting-zip-files-in-adobe-air-with.html
分享到:
相关推荐
NULL 博文链接:https://lxs647.iteye.com/blog/1179043
dreamweaver的adobe air扩展Adobe_AIR.mxp
adobe air 安装包part1adobe air 安装包part1adobe air 安装包part1adobe air 安装包part1
Adobe AIR技术学习Adobe AIR技术学习
构建 ADOBE® AIR® 应用程序 目录 第 1 章: Adobe AIR 简介 第 2 章: Adobe AIR 安装 安装 Adobe AIR 删除 Adobe AIR 安装和运行 AIR 范例应用程序 Adobe AIR 更新 第 3 章: 使用 AIR API 特定于 AIR 的 ...
AdobeAIR.dmg
针对 HTML 开发人员的 Adobe AIR 语言参考包括 Adobe AIR API 的详细信息。Adobe AIR API 通过 window.runtime 对象可以用于基于 HTML 的 AIR 应用程序中的 JavaScript 代码。您还可以通过 air 对象引用这些类,即在...
adobe air 安装包partadobe air 安装包part
AdobeAIR是最新的播放器为用户提供方便
adobe air 连接 airplay功能
AdobeAIR入门教程,adobe公司内部资料,值得学习。
Adobe Air Programming Unleashed
adobe air 安装包partadobe air 安装包part
利用 Adobe® AIR® 技术,开发人员可以创建和打包跨平台游戏/适用于 iOS、Android、Windows 和 Mac OS 等主要平台的应用程序。
使用AdobeAIR开发android应用
air-ane-fullscreen, 在Android上,为 Adobe AIR启用 true 全屏支持 全屏显示,适用于 Adobe AIRa的一个最常见的抱怨是,他们无法获得 true 全屏屏幕上的屏幕导航栏( 。包含背面,家庭和任务按钮的按钮) 。如果你是...
Developing Adobe AIR Applications for Android Contents Getting Started Workflow for developing and testing an AIR for Android app Available Documentation Flash Platform tool support Installing the ...
flash adobe air 开发的财经音视频,rtmp推送。
adobe AIR 安装环境,AIR运行时,没这个,AIR程序运行不了
Mac 下 图片标注工具,非常方便,体验版能满足临时需求。注意安装markman前先安装Adobe AIR