Flash CS3 Documentation |
|||
| Programming ActionScript 3.0 > Display programming > Manipulating display objects > Caching display objects | |||
As your designs in Flash grow in size, whether you are creating an application or complex scripted animations, you need to consider performance and optimization. When you have content that remains static (such as a rectangle Shape instance), Flash does not optimize the content. Therefore, when you change the position of the rectangle, Flash redraws the entire Shape instance.
You can cache specified display objects to improve the performance of your SWF file. The display object is a surface, essentially a bitmap version of the instance's vector data, which is data that you do not intend to change much over the course of your SWF file. Therefore, instances with caching turned on are not continually redrawn as the SWF file plays, letting the SWF file render quickly.
|
NOTE |
|
You can update the vector data, at which time the surface is recreated. Therefore, the vector data cached in the surface does not need to remain the same for the entire SWF file. |
Setting a display object's cacheAsBitmap property to true makes the display object cache a bitmap representation of itself. Flash creates a surface object for the instance, which is a cached bitmap instead of vector data. If you change the bounds of the display object, the surface is recreated instead of resized. Surfaces can nest within other surfaces. The child surface copies its bitmap onto its parent surface. For more information, see Enabling bitmap caching.
The DisplayObject class's opaqueBackground property and scrollRect property are related to bitmap caching using the cacheAsBitmap property. Although these three properties are independent of each other, the opaqueBackground and scrollRect properties work best when an object is cached as a bitmap--you see performance benefits for the opaqueBackground and scrollRect properties only when you set cacheAsBitmap to true. For more information about scrolling display object content, see Panning and scrolling display objects. For more information about setting an opaque background, see Setting an opaque background color.
For information on alpha channel masking, which requires you to set the cacheAsBitmap property to true, see Alpha channel masking.
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00000158.html