如何在Flash Builder上提取obb文件?

问题描述 投票:1回答:2
var zip:FZip = new FZip();
zip.load(new URLRequest("xx.obb"));

这些代码不起作用。它抛出“未知记录签名:”错误。

你是怎么提取.obb文件的?

android air flash-builder
2个回答
0
投票

你需要阅读它吗?如果是加载游戏我认为这是一个很好的加载方式,所以最好从特定的路线加载它

例如:sdcard / android / obb / filename.obb


0
投票

如果您的obb文件与任何其他zip文件一样,那么您可以这样处理它。首先,您需要提取要提取的文件列表(可能是您知道的所有文件)。

以下是获取文件的一种方法:

 private function obbFileUnpackingRoutine(event:Event):void{
    addChild(obbUnpackScreen);
    obbUnpackScreen.obbProgress.scaleX = zipCount/filesToUnpack.length;
    setChildIndex(obbUnpackScreen, numChildren -1);
    for (var i:uint = 0; i<24; i++){
        if (zipCount == filesToUnpack.length){
            zipDone = true;
            removeEventListener(Event.ENTER_FRAME, obbFileUnpackingRoutine);
            removeChild(obbUnpackScreen);
            var fr:FileStream=new FileStream();
            var str:String = File.applicationStorageDirectory.nativePath;
            var cacheDir= new File(str +"/YourSettings");
            fr.open(cacheDir.resolvePath("isObbUnpacked.pnr"),FileMode.WRITE);
            fr.writeObject([zip.getFileCount(),zipCount]);
            fr.close();
            return
        }
        var file:FZipFile = zip.getFileByName(filesToUnpack[zipCount])
        var cacheDir:File= null;
        var str:String = File.applicationStorageDirectory.nativePath;
        cacheDir= new File(str);
        var fileContents = file.content
        var fr:FileStream=new FileStream();
        fr.open(cacheDir.resolvePath(file.filename),FileMode.WRITE);
        fr.writeBytes(fileContents);
        fr.close();
        zipCount++;
    }   


}

如果内存允许,您可能希望直接从zip文件加载文件,因此您无需解压缩它们。当然必须提取任何只能通过urlRequest访问的文件但是你可以使用byteArrays加载png文件,mp3文件和你自己的自定义文件

我的obb文件有数千个小的mp3文件,在allWinner A10处理器上提取可能需要3分钟。直接加载意味着它可以立即获取文件。几乎没有任何延迟。

© www.soinside.com 2019 - 2024. All rights reserved.