簡體   English   中英

使用Air as3 Flash壓縮許多文件

[英]zip many files with Air as3 flash

好 。 我有能力,但仍在學習。 這是我在AIR中編寫的程序。 基本上,我需要從給定的文件夾中獲取混合類型和內容的文件,並將其壓縮。

這是我整理的代碼,可以正常工作。 我的問題是zip中的文件都包含零字節。 完全是空的。 我錯過或做錯了什么?

import flash.filesystem.File;
import flash.events.Event;
import deng.fzip.*;

var directory:File = File.desktopDirectory.resolvePath("FOLDER/");

var zip:FZip = new FZip(); 
var files:Array = directory.getDirectoryListing();
for(var i:uint = 0; i < files.length; i++)
{
    zip.addFile(files[i].name, files[i].data);
    trace(files[i].name);
}

var ba:ByteArray = new ByteArray(); 
zip.serialize(ba); 
ba.position = 0; 
var finalZIP:File = File.desktopDirectory.resolvePath("TEST.zip"); 
var fs:FileStream = new FileStream(); 
fs.open(finalZIP, FileMode.WRITE); 
fs.writeBytes(ba); 
fs.close();

EDIT =:在運行代碼時,我在錯誤面板中注意到了這一點。

  ....app\scripts_classes\deng\fzip\FZipFile.as, Line 362   Warning: 1106: Empty statement found where block of code expected. Did you type ';'     accidentally?

從我看來,這似乎還不錯,但是后來我沒有寫Fzip腳本。

File.data僅在通話結束后填充File.load

要同步加載字節,請查看FileStream 這些文檔提供了一個摘要。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM