PDA

View Full Version : Best Uses for cacheAsBitmap (as2)


maskedMan
05-12-2008, 06:45 PM
I'm aware that it is probably a good idea to use cacheAsBitmap when you are dealing with complex vector objects that seldom need to change shape/scale/color (in my case, I'm dealing with a map of the US where each state is its own vector object and they only ever change color when the user requests a new data set). But there are a few other instances where I might be able to use cacheAsBitmap but am not sure whether doing so will actually help me.

For example, I have a legend consisting of a fairly simple gradient bar and several bits of text. Now, the gradient box is of course only four vector points but the fill is a gradient. Would it make sense to turn on cacheAsBitmap for this gradient bar? Does the mathematical computation required to generate the gradient cost more processing power than storing the image as a bitmap?

But let's go a step further... what if the gradient bar legend is inside a movie clip that also contains a background and some text data that only changes in the event that the user selects a new data set? Would I then be able to turn on cache as bitmap for the whole clip?

hexvector
06-15-2008, 06:52 AM
Yes, for complex vector data that *does not* scale or rotate it is good to cache it. Text is vector as well and is fairly slow to move or animate if not cached due to its complexity.

You will good to cache the entire container sprite. Even if it has text inside of it that is selectable it can help. Since you can't set cacheAsBitmap on a textField it is common to put it in a sprite and turn on caching.

It does require memory though to process the vector into a bitmap and store it. But initial performance cost and memory is negible if your sprite is small.

Sly Raskal
06-24-2008, 05:03 PM
Does setting a MovieClip's cacheAsBitmap property to true and adjusting the MovieClips alpha values a detriment?

Are scale and rotation the only two characteristics that are detrimental to using cacheAsBitmap?