• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Lesson 11. Alpha Channels and Masks > Experimenting with an Alpha Channel

Experimenting with an Alpha Channel

In the first part of this lesson, you will experiment with an image that has been created with an alpha channel. You will also try a new behavior from the Library Palette that will allow you or another user to move a sprite around on the stage while the movie is running. This will allow you to better see how the alpha channel mask is working.

Open Start.dir in the Start folder of the Lesson11 folder and save it in your Projects folder as Alpha.dir.

The movie contains only a background image of some shapes; you will place the image containing an alpha channel mask over them.

Choose File > Import to open the Import Files dialog box. In the Media folder for Lesson11 double-click the file glassWin.tif and then click the Import button.

This is the image that contains the alpha channel. Although this image was created as a 32-bit image (as must be the case for an image to contain an alpha channel), you can still use it in a movie otherwise created for 8-bit playback.

In the Image Options dialog box, make sure that the Color Depth option is set to Image (32 bits) and then click OK.

The image appears as cast member 2 in the cast.

Figure .

Drag the glassWin cast member to frame 1, channel 2, of the score.

The new sprite, a stained-glass window, appears centered on the stage. You can already see that some of the background image shows through the glass. Now you need to add a behavior to make the movie loop and a behavior to make the stained-glass draggable.

In the behavior channel, click an unused frame; then choose Window > Inspectors > Behavior to open the Behavior Inspector. Use the New Behavior button to create a new behavior and name itLoop.

For the event, choose Exit Frame. For the action, choose Navigation > Go To Frame and set the frame to 1. Click OK to close the Specify Frame dialog box.

The new behavior appears as cast member 3 in the Cast window. Drag this new behavior to frame 28 of the behavior channel.

The movie should now loop back to frame 1 when it is played.

Although you can see the background image showing through the window, the full effect is more impressive when you can move the stained-glass to view different areas of the background. One way to achieve this is to allow the user to move the stained-glass window around on the stage. The Library Palette has a behavior designed just for such a purpose.

Choose Window > Library Palette. Click the Library List button and choose Animation > Interactive.

Find the Draggable behavior and drag it onto the glassWin sprite in channel 2.

The Parameters dialog box opens.

Make sure that the Constrain to Stage box is unchecked and then click OK. Close the Library Palette window.

When the Constrain to Stage box is checked, the sprite can be moved by the user, but its range of movement is limited so that no part of the sprite can be moved off of the stage. Unchecking the property enables a greater degree of movement, which is better for this example.

Set the ink effect of the glassWin sprite in channel 2 to Background Transparent.

Save your work and then play the movie.

The Draggable behavior allows the sprite to be moved, so try moving the stained-glass sprite around on the stage. As long as you hold down the mouse button on the sprite, you can move it. When you release the mouse button, the sprite stays in its current position. To make the alpha channel effect even more like looking through stained glass, you can set the sprite's Dither property to True.

With the glassWin sprite selected, click the Property Inspector button on the toolbar. Choose the Bitmap tab (it looks like a paintbrush) and find the Dither check box. Make sure the Dither box is checked.

By combining the alpha channel effect with dithering, the image gives even more of the impression that you are viewing the background through antique colored glass.

If you have access to a paint program that supports alpha channels, you can use it to open the glassWin.tif file in the Media folder and inspect the alpha channel contents. What you will find is a gray-scale image with the degree of darkness corresponding to the degree of transparency of the image. This same effect can be achieved entirely within Director by using a mask cast member and the Mask ink.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint