PDA

View Full Version : Importing Bitmaps from an SWF exported via Flash CS3



megadev
January 29th, 2009, 08:02 AM
Hi everyone,

I'm currently integrating one of my games with the SDK of a certain publisher (who shall remain nameless), but I'm having real problems. They require all games to load their content (ie. images, sounds etc) from an external SWF, like so:



private var __gameScreen:MovieClip;

private function onContentSwfLoaded(result:MediaLoaderResult):void
{
// Store our content and add it to the stage
var contentSWF:MovieClip = result.content as MovieClip;

assert(contentSWF != null, "content swf is null");

// Create a reference to the game screen movieclip in the content SWF
__gameScreen = contentSWF.stateGame;

// Set up the game timeline
addChild(__gameScreen);
}
The problem here is that I really don't want to have to use MovieClips as all of my games use nothing but BitmapData, so I'm wondering if there's a way of extracting a Bitmap or BitmapData from an SWF? It doesn't appear that Flash CS3 caters for this though - you can assign an "instance name" to a MovieClip, but not a Bitmap as far as I can tell. I usually develop in Flex Builder 3 but I've not managed to extract anything from an SWF exported from it, probably because you can't assign instance names to objects, I'm guessing. My current work-around for this problem is to draw each MovieClip to a BitmapData object, but this is very long-winded and probably not too efficient either. Anyway, enough of my ramblings - if anyone could give me some idea of where I'm going wrong (assuming I'm going wrong), I'll buy you a pint or three! :-)

Cheers,

Mike.

cbeech
January 29th, 2009, 09:56 AM
you can assign the 'name' property of any Display Object under 3, including a bitmap object - additionally (a great 'new' feature) you can also now assign a Class name to a bitmap in the Library and instantiate them via a constructor. you can, as you've said, draw them to a bitmapData object - but I guess i just don't understand why you really would need to, rather than just using it as the instance of the loader object you've loaded it into, you should be able to reference the instance and control it (in fact far more control than using a bitmap) within the scope you are bringing it into.

one thing that may help is to declare the property 'outside' of the handler method, then 'assign' the content to the property, then you can reference the instance anywhere in your code - which is pretty much what you're doing with the __gamescreen property - so i guess i still don't understand why this is an issue.