How Bitmap Caching Works
How Bitmap Caching Works
When you turn on bitmap caching for any given movie clip, the player converts the contents of the movie clip into a bitmap, which it generates and then stores in memory alongside the original vector data equivalent. The renderer then displays this bitmap in the place of the vector data by copying the image from memory onto the Stage.
This process essentially makes the renderer’s life easier, because it doesn’t have to update the movie clip each frame. Instead the process only has to draw the bitmap it generated once, and from then on it simply copies the bitmap from memory onto the Stage. If you change the movie clip or its contents, Flash regenerates the bitmap. There is little or no visual difference when a movie clip has bitmap caching turned on. You may notice a very slight difference because the vector data is snapped to the nearest whole pixel when the bitmap is generated. Bitmap caching also works perfectly well with nested movie clips (movie clips inside movie clips).
To put it in simple terms, by turning on bitmap caching for a movie clip, you are essentially telling Flash Player, “Hey Renderer, I’ll make your life a little easier. Freeze this movie clip and display it as a bitmap instead, because this movie clip or its contents are not going to change very often, if at all. They are static.”
Turning Bitmap Caching On and Off
Bitmap caching comes in the form of an additional movie clip property that can be switched on or off at author-time using the Property inspector and at runtime using ActionScript, on a per movie clip basis.
Using the Authoring Environment
You can turn bitmap caching on or off for any movie clip in the authoring environment using the Property inspector. Selecting this option disables bitmap caching for all movie clips by default.
To turn bitmap caching on select the desired movie clip instance on Stage by clicking on it. Then, open the Property Inspector from the Window menu. Select Window > Properties > Properties, or use the keyboard shortcut Control + F3.
In the lower right corner of the Property inspector underneath the Blend field, select the Use Runtime Bitmap Caching option for the selected movie clip by clicking the checkbox. Bitmap caching is deselected or turned off by default for all movie clips.
Using ActionScript
You can also turn bitmap caching on and off at runtime using ActionScript. Every movie clip object now has a new ActionScript property called cacheAsBitmap
. To turn bitmap caching on for a movie clip, you simply need to set the value of its cacheAsBitmap
property to true
using the following code:
someMovieClip.cacheAsBitmap=true; //Turn Bitmap Caching ON
Similarly, to turn bitmap caching off for a movie clip using ActionScript, you simply need to set the value of its cacheAsBitmap
property to false
as follows:
someMovieClip.cacheAsBitmap=false; //Turn Bitmap Caching OFF
You can also determine if a movie clip has bitmap caching turned on by retrieving the value of the cacheAsBitmap
property:
isCached=someMovieClip.cacheAsBitmap;
Comments