When you place a visual cast member on the Stage, it's automatically surrounded by a rectangular bounding box. This bounding box usually appears as a white rectangle behind the sprite (Figure 8.2). (If the sprite is based on a vector-shape cast member, the rectangle is filled with the cast member's background color, which is usuallybut not necessarilywhite.)
If the sprite itself is perfectly rectangular, the rectangle is completely hidden behind the sprite (Figure 8.3). But with most sprites, at least part of the rectangle remains visible, resulting in unsatisfactory compositing against anything other than a pure white background (Figure 8.4).
You can easily solve this problem by changing the ink effect applied to the sprite. (For more information on ink effects, see "Sprite Ink Effects" in Chapter 3.) The default ink effect applied to every new sprite is Copy. If you change the ink effect to Background Transparent, the white rectangle disappears (Figure 8.5). This is because the Background Transparent ink effect makes all white pixels in a sprite (or all pixels of the background color you specify) invisible, allowing whatever is behind those pixels to show through.
The Background Transparent ink effect is a quick, simple way to composite a sprite against a background. However, it only works for sprites based on a specific kind of cast member:
The cast member must have a pure, flat-white or solid-color background. (Note that many backgrounds that seem to be solid actually have slight color variations. Uneven color backgrounds are especially common in cast members imported from JPEG files. Figure 8.6 shows what happens to background color variations when you use Background Transparent ink.)
If the cast member is a bitmap, it must have sharp boundaries, with no anti-aliasing, blurring, or smoothing. If the edges of the cast member are blended into the background in any way, there will be a "halo" around the sprite when Background Transparent ink is applied. (See "Eliminating Halos in Imported Images," later in this chapter.)
Select the sprite on the Stage or in the Score.
Set the background color in the Tool palette to match the background color of the sprite's cast member (Figure 8.7).
If the cast member's background is white, make sure the background color in the Tool palette is set to white.
If the cast member's background is a color other than white (Figure 8.8), set the background color in the Tool palette to match that color (Figure 8.9). (Use the color picker if necessary.)
In the Property Inspector, select the Sprite tab.
In the Sprite tab's Ink menu, choose Background Transparent (Figure 8.10).
The sprite's background becomes invisible on the Stage (Figure 8.11).
If there are pixels in the sprite that are the same color as the background, they become invisible as well (Figure 8.12).
In order for the Background Transparent ink effect to work, the background color set in the Tool palette must match the cast member's background color exactly. If necessary, sample the sprite's background color in the Paint window or in an external image-editing program to get the color's exact RGB values. Then match those RGB values in the Tool palette, using the color picker if necessary.
or
Change the pixels (either foreground or background) to a different color (Figure 8.14); then follow the steps in the previous task.
The Matte ink effect takes more processing power than Background Transparent and can slow down your movie, so avoid it if you can.
There are other ink effects that will make background pixels transparent, such as Transparent, Reverse, and Ghost. (See the "Score Ink Effects" sidebar in Chapter 3 for descriptions of all the ink effects.) However, unlike Background Transparent and Matte, these other effects may change the appearance of foreground pixels as well (Figure 8.15).
The Background Transparent and Matte ink effects work for both vector and bitmapped cast members. The remaining compositing techniques in this chapter are for bitmapped cast members only.