I thought today I would post something about Bitmap and Bitmap Data in AS3.
Bitmap is a display object which wraps the BitmapData within it. The BitmapData is the array of data used to form the pixels in the image. Now a point to note here is that you can’t use use the BitmapData of one state of a movieclip and expect it to gather all the frames. What it does is it takes a photograph sort of and gets its pixel data value.
Ok so all this may seem like a lot of text. Let’s just jump into flash and figure this out. Let’s start by creating a movie clip with a text field inside of it.
Give this movieclip an instance name of mc and hit f9 to get into the actionscript panel.
Now we begin by declaring our variables and defining their properties.
var newBitmap : Bitmap;
var bd:BitmapData=new BitmapData(mc.width,mc.height,true,0×000)
the parameters we pass in when constructing a BitmapData are:
1) width- compulsory
2) height -compulsory
3) alpha
4) fill colour
We now proceed to tell the bitmap what data to copy and then to tell the bitmap which bitmapdata it should be wrapping.
bd.draw(mc)
newBitmap = new Bitmap(bd);
we turn on smoothing for the bitmap (this is quite processor heavy for complex images but for this illustration I would like it)
newBitmap.smoothing=true;
finally we add it to the display list
addChild(newBitmap);
lets compile and check it out

So now obviously we have a new display object called newBitmap. This has the display object properties and methods attached to it.
But there is one drawback of using the Bitmap to copy movieclips you already have drawn out or text or whatever.
Here it is.

The image you have just created is indeed a Bitmap. If you scale it or whatever, the image is going to be pixelated. Comparing it to vector graphics or the text you just copied, there is a noticeable difference in quality.
There are of course uses of this to create objects which wont ever scale. I think its really handy. Besides, this is just the first step in many more things you can do with the bitmapdata. I will try and post more about it. It is truly an amazing class. I am going to try and have another post about this in the near future.
Download the source here Bitmap-Data example