Extract .obb files in as3

Tuesday, July 8, 2014

I have an app that I made using Flash CS6 and Adobe AIR which exceeds the Google Play Limit of 50Mb. So I am using expansion files which is an .obb file inside which are several swf's which I need to extract using as3. The expansion files get downloaded to the /Android/obb/my_package_name/ folder and I am able to find it in my code below, but I got stuck while extracting the files from the obb file. Using FZIP Class did not help (It extracts .zip files but not .obb). Following is my code



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 */
}






http://ift.tt/1xKP1un