0
votes

i've created a full spectrum color wheel Sprite object that is composed of 1440 vector triangles, or slices if you will.

since i want to animate the color wheel, i've activated the display object's cacheAsBitmap property. however, caching the vector as a bitmap does not increase performance during animation – it remains slow, jumpy.

importing a PNG screenshot of the color wheel into the library with lossless compression, converting it to a Sprite, and rotating this new image asset performs great during animation.

why does an uncompressed PNG image asset import out perform the same vector image with cacheAsBitmap property set to true?

1

1 Answers

6
votes

Because each time you rotate the object, it has to recalculate a new bitmap.

cacheAsBitmap is only intended for objects that are being translated, not rotated; from the docs:

The cacheAsBitmap property is best used with movie clips that have mostly static content and that do not scale and rotate frequently. With such movie clips, cacheAsBitmap can lead to performance increases when the movie clip is translated (when its x and y position is changed).

This is because the cached bitmap is copied pixel-by-pixel directly to the display surface (for speed -- this is called blitting). Applying transformations to the bitmap every time it is rendered would be silly for objects that are rotated only once in a while. Recalculating the bitmap only when transformations are applied is a design decision which increases performance in the most common case, where transformations other than translation are infrequent.