Spotlight 1.0 is the result of an experiment with alpha gradient masks in Flash. As many of you may know, in previous versions of flash it was difficult if not impossible to have an alpha gradient mask. Now with Flash 8 we can do it easily using the cacheAsBitmap function.
There are a few steps involved in the process
- You can create your mask two ways(there are more, but these are a good place to start).
- You can create an inverse mask in photoshop and export as a .png file. Then import that file into flash as your mask.
- You can create the mask directly in flash. With the black and white gradient tool selected, click on the white slider and dial down the alpha value of the "white" color. See figure 1.
- Once you've created your mask, place it on the stage. Make sure to give make it a movieclip and give it an instance name. I called mine "mask".
- Then choose an image you want to mask, place it on the stage and contain it inside a movieclip. Give that movieclip an instance name, I called mine "img_mc".
- Now lets go into the action panel. The reason we can now have a gradient mask is we're going to cache our movieclip as a bitmap. we will put this code into our actions panel:
mask.cacheAsBitmap = true;
img_mc.cacheAsBitmap = true;
Now we have the alpha data in more than 1 bit, which is what flash offered us before Flash 8. 1-bit alpha is either on or off. That's why in previous versions even when you had a gradient on your mask it would still have a sharp edge.
- Finally we're going to apply the mask. Put in this code:
img_mc.setMask("mask"); Now we've applied the "mask" movie clip to the "img_mc" movieclip as a mask. Go ahead and test your movie.
You can download the source files here. As always if you have questions you can email me.