
Ok you want to take a snapshot of a movieclip, sprite, displayobject, shape or just simply the whole stage?
That is a simple task to accomplish in AS3. Below a reusable function I wrote while working for one of our clients:
private function getBitmapData( target:DisplayObject ) : BitmapData { if ( bd ) { bd = null; } //target.width and target.height can also be replaced with a fixed number. var bd : BitmapData = new BitmapData( target.width, target.height ); bd.draw( target ); return bd; }
you want to display the captured bitmapdata on the stage or inside of a Sprite? Again this is no problem:
private function displayCapturedBitmapData():void { var bmp:Bitmap = new Bitmap( getBitmapData( myImage ) ); addChild(bmp); }
That’s it, now you know how to create screenshots of your flash movie.

The AS3: Take a screenshot of any Displayobject by Tiago's Weblog, unless otherwise expressly stated, is licensed under a Creative Commons Attribution 2.5 Switzerland License.



This only work for bitmaps less than I think 4000 pixels wide. That is unless Adobe increased that limit. You can go up to 10,0000 pixels with a custom class. If you Google unlimitedBitmapdata you should be able to find a blog post about such a custom class.
Thanks for the comment Jason, when using Flash Player 10 you can use a total of 16’777’215 pixels, which would mean a square of roughly 4095×4095 pixels.
That doesn’t mean that the max width of a bitmapdata is 4095 it can be whichever width you want as long as the total amount of pixels is equal or less than 16’777’215 pixels. Not sure if FP10.1 raised the bar again, but at the end, I don’t think that anyone wants to create such high bitmapdatas and if they do then they can easily split them as they need.
Hi,
what about snapshottnh a 3d object?
Suppose I have a Sprite, then i Rotate it and move it in the 3d space.
Then I want to snapshot the rotated&moved sprite, how can I do that?
thanks
That’s basically the same, the snapshot is being created of the current visible portion of the screen of the defined Sprite.
Hi.
Is it possible to take a print screen of the stage using flash cs4 as3?
Yep absolutely, you can use the same method like i’ve shown in this post.
Thanks, works well
Nice one, thanks for the code!
Hi, thanks for the code! I cannot seem to figure out how to make a printscreen of the stage containing many displayobjects.
example: my stage contains many movieclips which are placed together to form one image.
Ive figured out how to place these displayobjects into one screenshot but the problem is that each displayobject is centered in the screenshot. I need the screenshot to portray the displayobjects in their original position. Is there another option than placing all the diffrent displayobjects into one movieclip?
hopefullly ive ilustrated the problem clearly…
Ok, found the solution and it was also posted here earlier. just use ‘stage’ as myimage. for some reason this didnt work the first time round but now does yay! ^-^
This works only if the origin of display object is in upper left corner; if it is e.g. in center, bitmapdata is filled in draw command around the upper left corner leaving down-right part empty
That is absolutely correct, bitmap data always starts at the registration point. so if you have a registration point centered the bitmap data would miss the upper and the left part of the display object. Nevertheless when working on a pure AS3 project your registration point is anyway set to 0,0 upper left (unless you change it ). Valid point. Thanks for the warning
Mr. Anonymous
If you’d like to adjust the center point of your screenshot for centered display objects you can use a matrix to shift it over.
var rect:Rectangle = new Rectangle(0, 0, target.width, target.height);
var matrix:Matrix = new Matrix();
matrix.translate(target.width/2, target.height/2);
var bd:BitmapData = new BitmapData(rect.width, rect.height, true, 0x00000000);
bd.draw(clip, matrix);
It doesn’t work for me. I’m a bid noob but this is exactly what i am looking for. I have multiple movieclips overlayed and i want to make 1 image of it. I pasted the codes into the action panel and when i run the swf nothing happens. Don’t know when he makes the snapshot or when he shows the snapshot. I feel kinda stupid..
Can you maybe zip the files or something so i can take a look at it? Let me know. I would really appreciate it!
Sorry if my english isn’t perfect.
Nvm mate! Already got it working
cool
Just what I needed. Thanks. AS3 I will tame you!