Skip to main content
May 24, 2013
Answered

How to reduce memory usage when loading bitmaps from the library?

  • May 24, 2013
  • 1 reply
  • 987 views

When I use BitmapData.loadBitmap() to load an image from the library and then attachBitmap() to add it to a MovieClip it takes a lot more memory as opposed to just having the same image inside a MovieClip statically in a frame on it's timeline.

The function dispose() not only clears the BitmapData object but also destroys the previously attached bitmap inside the MovieClip, so it can not be used to free any memory.

Is it how it is supposed to be or is there any other way to dynamically attach bitmaps with memory usage comparable to just having them on stage?

This topic has been closed for replies.
Correct answer kglad

you can do the same with movieclips: create a bitmapdata instance and use the draw() method to overlay as many as needed.

1 reply

kglad
Community Expert
Community Expert
May 24, 2013

add them to (or convert them to) movieclips and use attachMovie to dynamically add them.

May 24, 2013

Unfortunately, I need to produce one flat image, so I have to combine different bitmaps  into one "on the fly".

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 24, 2013

you can do the same with movieclips: create a bitmapdata instance and use the draw() method to overlay as many as needed.