Take the 2-minute tour ×

i have another piece for more advanced guys than me ;)

I am developing a simple flash application to create your own coat of arms. When finished creating, it would be nice to save it as an image to a client's computer or to a database, i am not sure yet. The problem is making the image from swf content - i mean not the whole content, just a part of it, where the COA is. I have found some eamples on the web using some image encoders and PHP, but i cant't understand how it works. Could anybody be so kind to explain me the basic principles of this? I want to make it as simple as possible.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

First, draw the image (Sprite or MovieClip, etc) into a BitmapData:

var b: BitmapData = new BitmapData(640, 480, false, 0xffffffff); 

Then, use e.g. as3corelib to encode the BitmapData into PNG or JPG files.

var ba: ByteArray = PNGEncoder.encode(b);

Then, for Flash 10, you can immediately get the user to save the image to a file, using FileReference's save method.

share|improve this answer
i think i understand, but it seems like saving only a single movieclip to an image, dont you know, how can i make this for a cut-off of the stage, lets say a rectangular area, that may contain more movieclips? something like a screenshot, but not a whole movie area... thanx anyway –  Dungeo May 2 '09 at 9:00
a stage is also considered as a displayobject, so you can draw the stage to the bitmapdata. use the matrix parameter of draw function to set the offset of the crop rectangle. –  yuku May 5 '09 at 9:07

This seems to be a popular question lately. So I don't completely reiterate all that information, instructions for saving the image data, once you've obtained that as BitmapData, are here:


But, first, to get the image data, you'll need to pull it out of whatever MovieClip/Sprite, whatever you have it in. To do this, you simply do:

var myBitmapData:BitmapData = new BitmapData(desiredWidth, desiredHeight, isTransparent, backgroundColor); myBitmapData.draw(mcToBeSavedToImage);

Where mcToBeSavedToImage is the movieclip you want to turn into an image. The BitmapData reference is here, if you need it - it has other examples: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/BitmapData.html

Hope that helps!

share|improve this answer

Your Answer


