I got tired of writing the Bitmap and Sprite Conversion code in AS3 multiple times and finally decided I’d write a small utility that would easily do this for me.

Usage:
Let’s say you have some some Sprite on the stage called _mcSprite that you want to become a bitmap, then you would do the following:
[as]var tmpBitmap:Bitmap = DisplayConverter.spriteToBitmap(_mcSprite);[/as]
DisplayConverter.bitmapToSprite() is also included. Both functions include an optional second parameter if you wish to enable smoothing.

Get the open source class here.

Update:

I just realized that the spriteToBitmap function did not maintain the transparency of the original. This is because the BitmapData constructor defaults the fillColor to opaque white instead of transparent. This can be fixed by setting the alpha byte of the ARGB hex code to “00″ instead of “FF”. For example:
[as]var bitmapData:BitmapData = new BitmapData(sprite.width, sprite.height, true, 0x00FFFFFF);[/as]
The class in the download link above has been updated with this issue resolved.

This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 3.0 United States License.