在as3中提取.obb文件



我使用Flash CS6和Adobe AIR制作了一个应用程序,超过了Google Play限制的50Mb。所以我使用的扩展文件是一个。obb文件,里面有几个swf,我需要使用as3提取。扩展文件下载到/Android/obb/my_package_name/文件夹,我能够在下面的代码中找到它,但是我在从obb文件提取文件时卡住了。使用FZIP类没有帮助(它提取。zip文件,但不提取。obb)。以下是我的代码

file = File.userDirectory.resolvePath(path + "/" + filename);
if (file.exists)
{
    loadSwf();
}
function loadSwf():void 
{
    fileStream = new FileStream(); 
    fileStream.open(file, FileMode.READ);
    bytes = new ByteArray();
    fileStream.readBytes(bytes);
    trace(bytes);
    fileStream.close(); 
    var cont:LoaderContext = new LoaderContext();
    cont.allowCodeImport = true;
    applicationLoader = new Loader();
    applicationLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleAppLoaded);
    applicationLoader.loadBytes(bytes, cont);
}
function handleAppLoaded(e:Event):void 
{
    addChild(applicationLoader);
    /* Now how to extract the swf's from within the obb */
}

。Obb是zip文件,重命名它,然后使用fzip读取其内容。请注意,Google Play本身表示,在某些设备上。obb文件可能无法与应用一起安装。在这种情况下,他们提供免费的。obb文件托管服务,但如果你不想让用户等待。obb下载,你就必须切换到不同的系统。

我个人跳过这一步,直接下载到设备上丢失的文件(只有声音或某些情况下的图形),并将它们保存在磁盘上。

最新更新