Setting the background of a movie clip

You can set an opaque background for a movie clip. For example, when you have a background that contains complex vector art, you can set the opaqueBackground property to a specified color (typically the same color as the Stage). The background is then treated as a bitmap, which helps optimize performance.

When you set cacheAsBitmap to true, and also set the opaqueBackground property to a specified color, the opaqueBackground property allows the internal bitmap to be opaque and rendered faster. If you do not set cacheAsBitmap to true, the opaqueBackground property adds an opaque vector-square shape to the background of the movie clip instance. It does not create a bitmap automatically.

The following example shows how to set the background of a movie clip to optimize performance.

To set the background of a movie clip:

  1. Create a new Flash document called background.fla.
  2. Draw a blue circle on the Stage.
  3. Select the blue circle, and then select Modify > Convert to Symbol.
  4. Select the Movie clip option, and then click OK.
  5. Select the instance on the Stage, and then type my_mc into the Instance Name text box in the Property inspector.
  6. Select Frame 1 of the Timeline, and then type the following code into the Actions panel:
    /* When you set cacheAsBitmap, the internal bitmap is opaque and renders faster. */
    my_mc.cacheAsBitmap = true;
    my_mc.opaqueBackground = 0xFF0000;
    
  7. Select Control > Test Movie to test the document.

    The movie clip appears on the Stage with the background color that you specified.

For more information on this property, see opaqueBackground (MovieClip.opaqueBackground property) in the ActionScript 2.0 Language Reference.


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/00000870.html