BitmapData
The BitmapData class allows the creation and manipulation of bitmaps during runtime. This means you can create complex images without some of the performance problems associated with bitmaps on the timeline. You can also perform certain visual effects that would have been impossible in previous versions of Flash.Another nice feature of the BitmapData class is that it can also retrieve information about bitmaps, as you will see in this next example:
The preceding code does a lot of things. First, it imports the necessary class file. Then it creates an instance of the BitmapData object and loads the bitmap directly from the library. Next, the code creates an empty movie clip to hold the bitmap. After that, you instantiate a Color object, which you use inside the onMouseMove event. Then you create the event to trigger whenever the user moves the mouse, and you make sure that the mouse cursor is over the image. If the mouse is over the image, you pass the color of that pixel through the Color object you created to change the color of the rectangle.Test the movie and you will see that the rectangle changes to the color of the pixel the mouse is hovering over, as shown in Figure 1.14.
Figure 1.14. The BitmapData is an object with a great deal of potential for image manipulation.
