Learnosity Logo
Learnosity Banner Image

Reusing Bitmap data in Flex/AS3 Applications

If you are loading bitmap images (jpeg, png, gif) in a flex application you may want to display the same image multiple times. This was something that was impossible to do in Flash 7 but in Flash 9 with AS3 it's a doddle.

All you need to do to it create a new Bitmap from your existing bitmap by referencing the bitmapData object. This is means that it won't double the used memory:

// myOldBitmap is a currently available bitmap which has already been loaded from an external resource.

var myNewBitmap:Bitmap = new Bitmap(myOldBitmap.bitmapData);

How easy is that.

Cheers, Mark

Comments