I'm trying to load a swf file into another swf and then extract the assets from the first.
Both swf files are being created using OpenFL (compiled in FlashDevelop).
I can load the external swf easily and convert it to a SWF object (haxelib swf library).
But then I can't extract the images from the SWF?
var req:URLRequest = new URLRequest('TestSwf.swf');
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, function(e:Event)
{
var byteArray:ByteArray = cast(e.target, URLLoader).data;
trace(['ByteArray length', byteArray.length]);
trace(byteArray.length);
var slide_swf:SWF = new SWF (byteArray);
trace(slide_swf.hasSymbol("__ASSET__assets_img_0002_png"));
var sym:Dynamic = slide_swf.data.getCharacter(slide_swf.symbols.get("__ASSET__assets_img_0002_png"));
trace(sym);
var bmpd:BitmapData = slide_swf.getBitmapData("__ASSET__assets_img_0002_png");
trace(bmpd);
var bmp:Bitmap = new Bitmap(bmpd);
trace(bmp.width);
this.addChild(bmp);
});
loader.dataFormat = URLLoaderDataFormat.BINARY;
loader.load(req);
The output from running this is :
Main.hx:42: [ByteArray length,738913]
Main.hx:43: 738913
Main.hx:46: true
Main.hx:48: [00:DefineBitsJPEG2] ID: 1002, Type: PNG, BitmapLength: 531065
Main.hx:50: null
Main.hx:57: 0
You can see that the sym type is of DefineBitsJPEG2 which SWF can't convert into a Bitmap.
So how can I extract the assets from the SWF file? Or am I going about this in completely the wrong way??
Any help would be greatly appreciated!!