Temporarily work with a visual asset as a bitmap, by temporarily storing bitmap representation of the asset.
You need significant CPU processing power to composite and render moving vectors many times a second. In some cases, you can improve performance by treating the vector asset as a bitmap, behind the scenes. In simple terms, Flash Player takes a screenshot of the vector any time a major transformation, such as changes to rotation, alpha, or scale, occurs and composites the bitmap version rather than the vector asset itself.
Because the bitmap version is cached, you have no degradation of visual quality any time a major transformation occurs. However, the need to maintain an equivalent bitmap also means performance can actually worsen if you use this feature injudiciously. Therefore, bitmap caching is not recommended if the asset is rotating, scaling, or changing opacity frequently.
More directly, sometimes you need to temporarily convert a vector to bitmap to apply pixel-based effects, like filters and 8-bit masks. In some cases, this process is automatic, such as when you’re applying a simple filter like a drop shadow. In other cases, you must explicitly enable the feature.
This recipe adds only two lines of code to the very end of the prior the section called “12.11 Using a Drawn Shape as a Dynamic Mask” to use a drawn shape as a dynamic mask. The repeated code has been omitted.
sp.cacheAsBitmap = true; spMask.cacheAsBitmap = true;
By enabling bitmap caching for both the mask and maskee, both can be composited as bitmaps. Then you can use the gradient alpha values in the mask when displaying the underlying content.
the section called “12.10 Creating a Gradient Fill” for creating a gradient fill and the section called “12.11 Using a Drawn Shape as a Dynamic Mask” to use a drawn shape as a dynamic mask.