Using CacheAsBitmap effectively for FlashLite for Digital Home
As you might be hearing now a days about FlashLite on Digital Home, its like running Flash content on Set-top boxes. My previous post has a demo of Intel, which was given at its IDF.
In this post, we are going to talk about using cacheAsBitmap feature effectively while creating content for Set-top boxes.
FlashLite for Digital Home basically has a capability of Hardware Rendering, wherein the hardware has can render the Bitmaps avoiding the software(FlashLite) to take this burden. This results in increase in performance while rendering on set-top box.
Inorder to make make any vector on Stage to bitmap, we can use cacheAsBitmap property of that movieClip.
MovieClip.cacheAsBitmap = true;
Once this property is set to true, that movieClip will be converted to bitmap. So, while rendering it, hardware can take care of rendering this bitmap.
Applicable
This property is only applicable to MovieClips. Its not applicable to Buttons.
Enabling cacheAsBitmap
We can enable cacheAsBitmap either through actionscript or from Flash Authoring.
As explained above, using actionscript you can set the value of this property to true. By default, it will be false.
MovieClip.cacheAsBitmap = true;
In Flash Authoring, there will be a checkbox 'cache as bitmap' under Display panel of Properties menu.

opaqueBackground
In order to see a good improvement in the performance of your content on set-top box, you can use property of MovieClip opaqueBackground along with cacheAsBitmap.
In case of any non-rectangular movieclips, say a cirle, if you see the bounding box of that movieclip (which is a square), there are some parts which are transparent other than the circular fill. Rendering this transparent regions will be a bit overhead to FlashLite. The opaqueBackground property will fill these transparent areas of the movieclip with a specific color.
MovieClip.opaqueBackground = 0 //Fills the transparent regions with BLACK color
In your content, if your stage color is black, assigning the opaquBackground to black wont change its appearence. Using this we are removing the trasparent regions of the movieclip.
This will be in handy, while assigning the same color of your stage as opaqueBackground for all non-rectangular movieClips. This wont change the appearance of the movieClips either. Further you can see the improvement in performance.
Things to do:
- Use cacheAsBitmap on movieClips which have a very large vector data.
- Use this for text, as text will have a very large transparent areas.
- Can apply to the content which translates across the stage w/o any change in its content
- Apply on a content which scales w/o change in its content
Things to avoid:
- Try to avoid using many bitmaps in your app, as it will increase the size of your app.
- Try to avoid larger bitmaps, as they occupy more memory.
- It will be an over-head if you use a very large number of bitmaps. This might result in higher memory consumption.
- Donot use on rotating MovieClips.
- Applying cacheAsBitmap on video.
Hope you find this useful...