Age : 19Number of posts : 409Registration date : 2012-11-21Location : East London

Legit Alpha Gradient Masking Without Actionscript

So this is something that's bugged me for a while. I remember being able to have an alpha gradient as a mask in earlier versions of flash, so that I could take a solid object and make parts of it more or less transparent depending on the mask, but a few years ago when I tried to do this it wouldn't work right, and no one I talked to could tell me how to do it the proper way. Everyone said that they knew it could be done, but wasn't sure how. Well, recently I took it upon myself to do some research and rediscover this long lost technique, and it's fairly simple, so I've decided to make a small tutorial to share with you today.

THE PROBLEM

Now, a regular mask involves 2 layers. One layer is the shape that's getting masked, and the other layer is the mask itself that will show/hide parts of the shape beneath it depending on where the mask's shapes are. That looks like this:

Notice the layers showing which is the mask and which is going to get masked. On the stage, we see the big red area which will be what content is shown, and we see the text that is to bed masked. When the mask is applied, it looks like this:

See how the part of the text that was covered by the big red box in the previous image is now showing, whereas the rest is hidden? This is because the big red box is "masking" the text to only show where I want it to as defined by the box itself. To further illustrate this, say I want to make the text polka-dotted:

Now, this is useful for certain applications, but say I want to have a soft edge to the mask, so that it looks like it's fading in. You'd think I could just make a gradient on the mask and be done with it right? Well let's try that:

So this LOOKS like the end result will have a nice smooth transition for the text from solid black to completely transparent, right? Here's how it actually looks when the mask is applied:

So what happened? Where's our nice fading effect on the text? Well, the way these masks work is based on the SHAPE of the mask, and not the color or transparency. The mask will be applied wherever there is a shape. For example, this image has a striped mask on it, but I made it 100% transparent so you can't see it:

When the mask is applied, you can see it, even though it looks like there is nothing there:

A SOLUTION

So how do we get the desired effect? Well, a lot of people will simply make a solid gradient over top of what they want to mask if the background is a solid color. So for example, the background of my project is white, so I could make a white to transparent gradient box and position it over the text like so:

This looks OK, and creates the desired effect simply. But it's not a mask, and it's a cheap workaround. What if I had a wacky and complicated background?

That white gradient is no longer sufficient. So now what can we do?

THE SOLUTION

The solution is deceptively simple, and has to do with movieclip blending. So far in my project I have 2 layers: The Background, and The Text:

I want to mask the text so that it fades from solid to transparent. So my first step is to draw the mask. This can be on the same layer as the text, or on a new layer above it. Doesn't matter, but keep them close for convenience during a later step.

Turn the mask shape into a movie clip. Call it what you want, I'm going to call mine theMask.

It will vanish. This is normal. Next, select both the newly created mask movieclip, and the object you want masked (in this case, the text) and put them both into their own movie clip. I'm going to call my movieclip theContainer.

Once created, set your container movie clip's blending to Layer, and voila:

The mask is applied, fading out regardless of what is in the background.

This can be used to achieve a reflective effect, regardless of background:

notsureifsrs. I'm not bossing him but he's taking credit for something that's not his, whats the difference between this and someone posting NASF on their account? You all thought this was his tut and it was amazing just like people might assume that NASF was made by whoever posted that.

@supersmashbro wrote:yes this tutorial is on SP as well, I got permission from jeff (one of the admins on SP) to post this here because this was his original tutorial. I'm sorry if this caused confusion.

Yes he states it after but in the original place he says he made it himself, he should've just said it in the first place instead of saying he made it himself.