Make Your Flash Logo Bling with Alpha Gradient Masking

Aug 24th in Effects by Karl Macklin

In this tutorial we'll look at how to create a logo which incorporates alpha gradient masking in its animation. I'll explain some tips and tricks on how to get it working and avoiding some common problems.

PG

Author: Karl Macklin

Karl Macklin is a Flash developer, audio engineer and musician with interests in anything and everything Actionscript/Flash/Audio- Game and Webdesign.

Final Result

First, a quick peek at what we're aiming for:

Introduction

This is a beginner level tutorial during which I'll explain in detail how to create this logo and its animation. Along the way I'll mention a few words about gradient masking, bitmaps and shapes within flash, and the ActionScript it requires. Initially we'll briefly deal with some Photoshop techniques, but most image editing software should suffice.

Let's get started!

Step 1: Initial Design

Make sure you start off by downloading the source files. Open Logo.psd in the zip file.

You can also download and install the font used in this example, Lubalin Graph Bold. This is optional, as when you open the file, Photoshop will give you a warning that the font is missing, but for this exercise you can still follow along perfectly without it.

Opening up Logo.psd you should see this:

As you can see, we have a gray background layer and a text layer named "Text". If you have the Lubalin font installed you'll be able to change the text to something more personal, or you could change the font to your liking. The gray background layer is very superficial and I only chose it to help with illustrating the end result.

Step 2: If You Don't Have Photoshop

(You can skip this step if you use Photoshop.)

Here I'll briefly explain the layer styles used in Photoshop, so that those of you who want to copy the logo as verbatim as possible have a chance to do so in your own image editing software. It's not important that your logo looks alike, however.

  • Drop shadow, distance 6 px, spread 23%, size 10 px.
  • Inner shadow, distace 5 px, size 5 px.
  • Outer glow, yellowish, size 6 px.
  • Inner upwards bevel, size 32 px, 21% depth.
  • Contour, straight, 50% range.
  • Texture, simply a 4x4 pixel diagonal line pattern.
  • Color overlay, #A84D4A on the text.
  • Stroke, size 2 px, color #E5C477.

Hopefully this will give you an idea of how to create something similar. Again, it's not important for the sake of understanding the technique explained in this tutorial.

Step 3: Creating the Effect Outline

Before we jump into Flash we might as well do the one last thing needed in Photoshop; that is to create an outline for the effect we're about to make. Don't worry if it doesn't make sense yet, you'll see the whole picture very soon!

  • Turn off the layer styles on your text layer for now. Make sure this layer is selected.
  • Ctrl-click the text layer to select it.
  • Go to Select > Inverse, or hit Shift+Ctrl+I
  • Go to Select >Modify > Expand, choose 2 pixels and hit OK.
  • Hit Ctrl-C to copy your selection.
  • Create a new layer named "Outline" and select it.
  • Hit Ctrl-V to paste into it.

You should end up with this:

Select the Outline layer and hit "V" to select the move tool. Using your keyboard, align the outline so that it sits perfectly on top of the original text, like this:

Make sure the outline is fully white.

Step 4: Exporting the Images for Flash

Hide the Outline layer and the Background layer. Go to "Save for web and devices" and save as a PNG file. Name it logo.png. It should look like this:

Next, hide the Text layer and bring back the Outline layer. Save as "outline.png". It should look like this:

Make sure you save as high quality, transparancy enabled PNG!

Step 5: Preparations in Flash

Start up Flash and create a new AS3 file. Since the logo we're creating is 580 by 170 pixels in Photoshop, we'll use the same dimensions for our Flash file. Leave the FPS and background color as is.

Create and name these layers:

  • Shine
  • Mask
  • Outline
  • Logo
  • Background
  • Actions

Put them in the order as in the list, so that "Actions" is at the lowest Z-level and "Shine" at the highest. Now select the Background layer and create a rectangle covering the stage. Make its color a gradient going from dark gray (#222222) to light gray (#AAAAAA). Use the Gradient Transform Tool (hotkey F) to align it like this:

Lock the Background layer as we'll not be changing it any more.

Step 6: Importing the Logo into Flash

Select the Logo layer. Go to File > Import > Import to Stage, or hit Ctrl+R. Select the logo.png you previously exported from Photoshop. The image should line up perfectly in your Flash file. You can now lock the Logo layer as well.

Select the Outline layer and once again hit Ctrl+R, this time importing the outline.png. It too, should line up just right. Since the outline is currently selected, now would be a good time to hit F8 and turn it into a MovieClip. Name the MovieClip "Outline", then go ahead and insert an instance name of "outline" inside the properties panel. You should see something similar to this:

Now, head over to the Library panel and check the properties of your logo.png. Personally I'd set this to lossless quality, since this logo is something that is likely to be used as a header or something similar and I feel that in those cases you can afford to not skimp on the quality. It's your call, but it will look the best at lossless quality for sure!

Step 7: A Minor Adjustment

Have your outline instance selected and add a blur filter. Set it to 2 pixels in both X and Y blur properties, and choose high quality. This will make the end result much better looking.

You can go ahead and lock this layer too. Also, now would be a great time to save your Flash file!

Step 8: Creating the Mask

Select the Mask layer and then the rectangle tool. Deselect the stroke color if you have one currently applied.

Draw a rectangle, make it close to 60 pixels wide and 320 pixels tall. Then, with your shape selected, go into the colors panel and give it a linear gradient with three points evenly spread out (by points I mean the small handles that define the colors of a gradient). Choose any color for the points, but make sure you have the middle one at 100% alpha and the outer ones at 0% alpha. It should look like this:

Hit F8 with the shape selected and make it into a MovieClip called "Mask". Name the instance of the mask "theMask". Lastly, rotate the mask 45 degrees clock-wise. An easy way to do this is to first hit Q for the transform tool, then hold shift while rotating so it snaps to 45° stops.

Step 9: Animating the Mask

Go to frame 70 of the Mask layer in our main timeline and hit F5 to insert frames to this point. Right-click any previous frame and create a motion tween. Hold shift and then drag the mask to the right side of our stage. Also, create frames to frame number 70 for the layers Backround, Logo and Outline. The mask should go from here:

To here:

Step 10: Understanding Alpha Gradients

As you've probably figured out by now, we'll use the masks alpha gradient shape to gradually fade the outline in and out. Usually when you have a mask in Flash, you have it on one layer and turn that into a mask layer. The mask layer then has "child" layers whose content will be masked. Now, what happens if we do this with our current setup? This is the result:

As you can see, it's far from a smooth transition. There's no gradient behaviour whatsoever.

Why is this, then?

For alpha gradients to work, Flash must render your objects as Bitmaps, not shapes. Our current mask is definitely a shape (albeit inside a MovieClip) and is rendered as such. That can be fixed in two ways:

  • The Flash IDE way:

    In Flash CS4, have your mask selected. Under the Display section in the properties panel, check the "Cache as bitmap" checkbox.
    In Flash CS3, you can find it right under the blend modes labeled as "Use runtime bitmap caching".

  • The ActionScript way:

    My prefered approach is by using ActionScript. Mainly because as a developer (more than a designer), I want control over all aspects via code so I can apply any effect to any dynamically created object. Any object subclassing DisplayObject has a cacheAsBitmap boolean property. So in our example with the instance named "theMask" it is simply:

theMask.cacheAsBitmap = true;

Go ahead and create a keyframe in the Actions layer and insert that line of code.

Step 11: "But it's Still Not Working!"

For some mysterious reason, Flash cannot achieve the desired effect we're going for without ActionScript. Masked layers in the Flash timeline simply don't allow alpha gradient masking!

The solution is luckily very simple:

outline.mask = theMask;

As you can literally read from the code, this sets our instance "theMask" as the mask for our outline instance. Go ahead and put it in the actions layer.

Please take the following into consideration:

There is a bug within Flash regarding mask instances and the timeline. I've noticed the bug in the following hypothetical scenario:

Our mask instance spans from frame 1 to 70. Our other asset (the logo) spans up to frame 90. When Flash plays back between frame 71 and 90, the mask instance is not on the stage. If you're viewing the logo in a Firefox tab for example, then switch to another tab, then back again to the logo. You'll see the bug. You'll see it, if the playback is between frame 71 and 90, that is. The bug will show itself as the outline popping out and being unmasked. When the playback returns to frame one it returns to normal.

The conclusion we can draw from this is that if you mask something by ActionScript, make sure you keep the mask on the stage at all times to avoid the object being masked showing itself.

Step 12: Finishing Touches

Go ahead and test the movie now. It should look like this:

The effect is slightly too strong, so you can reduce the alpha of the outline instance to 75% and it will look a bit more subtle.

As a last finishing touch, we'll add a little sparkling shine effect to the logo.

  • Look in the source zip file and you'll find a shine.png.
  • Go ahead and import this to the stage onto the Shine layer on frame 59.
  • Place it on the upper right corner of the "g" character of our logo.
  • Convert it to a symbol so we can tween it.
  • Go to frame 69 of the same layer and hit F5 to insert a frame.
  • Right-click the relevant section and choose Create Motion Tween.
  • Zoom in around the area you're working with:
  • Go to frame 59 and transform the image to a barely visible size.
  • Go to frame 64 and transform it to its original size (or close to).
  • Go to frame 69 and transform it to a barely visible size.
  • Add a yellowish tint on the shine MovieClip in the properties panel.
  • Set the alpha to about 70%.
  • Add a yellowish glow filter as well.

Step 13: Summary

Your logo should now be 99% complete. You will still probably want to adjust when the animation restarts by inserting more frames after the mask has animated. Just remember what I mentioned earlier; make sure you keep an instance of the mask on the stage all the way to the end of the animation loop to avoid the mask display bug!

Here at the end of this tutorial you will hopefully realize how easily you can make changes to the logo, or apply the effect to any text logo with a satisfying result. Try experimenting by changing the thickness of the outline (Remember? We made it 2 pixels thick). Changing the text, font and colors can easily be done as well. Change the colors in the color overlay and stroke, or even better; experiment with your own layer styles!

The heart of the animation lies in the alpha gradient outline that lies within the typeface, so when you experiment on your own you should try to have some sort of stroke or outer border to keep this effect. Of course, anything goes, whatever is pretty to you is good!

I hope you liked this tutorial, thanks for reading!


Enjoy this Post?

We'd love your vote!

User Comments

( ADD YOURS )
  1. PG

    Proof August 24th

    hmmm, not bad

    ( Reply )
  2. PG

    Piotrek August 24th

    Nice and simple!

    ( Reply )
  3. PG

    Dario Gutierrez August 24th

    Pretty cool, sometimes I use some code to generate a dynamic mask like yours.

    ( Reply )
  4. PG

    Simon August 24th

    I like that the final result is really subtle. Not too flashy. The steps are clear and straightforward as well.

    Good job on this one, Thanks.

    ( Reply )
  5. PG

    Chris August 24th

    its a nice effect and one which people will learn from – but wether i would pay $150 for a tutorial on it…. Flash Tuts needs to impove quality in my opinion – why pay this much for one effect? There should be at least 5 differant effects in this tutorial to warent its cost. Any way, well done Karl

    ( Reply )
  6. PG

    antpaw August 24th

    wow i thought its impossible to have an alpha gradient in a mask!
    thanks!

    ( Reply )
  7. PG

    Karl Macklin August 24th

    I get the way you look at it Chris. I don’t necessarily see it as just buying “one effect”, although that would be the case for the reader who just skims through and seeks to duplicate the tutorial by the book.

    My goal was to show a good idea for animated design, while also sorting out some troubles that usually comes up.

    Glad you liked it!

    ( Reply )
  8. PG

    Eric August 24th

    I didn’t go through the steps to try this, but I’m wondering if there an error in your description.

    Under Step 8 you name the instance “myMask”, but in Step 10 (and 11) in the ActionScript code you use “theMask.cacheAsBitmap = true;”

    Should it be “myMask.cacheAsBitmap = true;” ?

    Not sure if this is referencing the instance name. Just a newbie trying to figure out ActionScript.

    ( Reply )
    1. PG

      Eric August 24th

      Also, I love this site. I’m learning a lot.

      ( Reply )
    2. PG

      Ian Yates August 25th

      Instance name corrected, thanks Eric..

      ( Reply )
  9. PG

    Tobias August 25th

    I like the gradient mask solution. I ran into this issue before and back then I could not resolve it.

    ( Reply )
  10. PG

    André August 25th

    It´s a great tutorial, it´s really a treasure, why?

    When you try to create a reflection of any object, this will be the best way to do this, in AS3 you also can create a class for this, wich can return an invert alpha masked of your object to create the reflection, so people, keep this in favorites because you will need it when you try to create reflections.

    Congratulations Karl.

    ( Reply )
    1. PG

      Karl Macklin August 25th

      Thanks for the encouraging words André!

      Hopefully you’ll see more tutorials from me in the future.

      ( Reply )
  11. PG

    Benjamin Reid August 25th

    Nice, finally a solution actually use a gradient as a mask. This has been a issue I’ve had for years with Flash and you’ve solved it.

    :)

    ( Reply )
  12. PG

    Jonathan August 25th

    Very informative. I’m new to Flash so just reading the steps, even though I’m not planning on doing the tutorial, will help me when I need to create stuff in Flash.

    ( Reply )
  13. PG

    Jonathan August 25th

    Also, what does the “IDE” in “Flash IDE” mean?

    ( Reply )
    1. PG

      André August 25th

      IDE:

      An integrated development environment (IDE) also known as integrated design environment or integrated debugging environment is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of:

      Font: http://en.wikipedia.org/wiki/Integrated_development_environment

      ( Reply )
  14. PG

    Adan August 26th

    Hey the FLA is not working on CS3 …why? I can’t see the code

    ( Reply )
    1. PG

      Tom Green August 31st

      Because the tutorial is a Flash CS4 Tutorial?

      ( Reply )
  15. PG

    Sebastián August 27th

    thanks! Very clear and with great results.

    ( Reply )
  16. PG

    enatom August 31st

    Wow, nice.

    ( Reply )
  17. PG

    Dani August 31st

    Great tutorial, I really like your idea! ;)

    ( Reply )
  18. PG

    dapas September 2nd

    nice tuts

    ( Reply )
  19. PG

    Szticks September 4th

    Just adapted this to a logo of my own that I’m making for a project. Thanks for a very helpful tutorial.

    ( Reply )
  20. PG

    flash2nd September 4th

    not sure how many people will use flash logo on regular html blog / website but this tutorial is great for those who would

    I like the effect

    ( Reply )
  21. PG

    wishMaster September 6th

    1. PG

      Ian Yates September 6th

      Yes it did!

      Thanks for letting me know, action is being taken.

      ( Reply )
    2. PG

      Ian Yates September 7th

      Update: Baltej Singh from edesignerz.net has kindly removed the tuts, replacing them with links instead.

      ( Reply )
  22. PG

    jawadahmad September 7th

    not bed

    ( Reply )
  23. PG

    Vishal September 9th

    Wow awasom…..

    ( Reply )
  24. PG

    StevoMighty September 10th

    I’m speechless… Pro Tutorial

    ( Reply )
  25. PG

    harene September 14th

    I’m learning AS3, what is the code for the blur flter?

    ( Reply )
    1. PG

      harene September 14th

      nevermind I found it, lol

      ( Reply )
  26. PG

    rolipolin September 16th

    Hi, thanks for the great tutorial. All of it’s very easy to understand except for the last part with as3. Are we supposed to put both lines of code in or just the last one. Is the code missing something – I keep getting an undefined variable error. Does the AS just need to be in one key frame or does it need to be tweened out? (sorry I’m a complete flash noob) Would anyone that understands please respond? Thanks! Also it’s important to note that the source code doesn’t open in CS3.

    ( Reply )
    1. PG

      Karl Macklin September 18th

      Hey there rolipolin,

      I’m not 100% sure I understand your question, but I’ll guess with a yes; you should have both lines of code in there.

      You only need to put it in a single key frame. Usually you put this in a separate “actions” layer to separate code from design elements.

      About the undefined variable error:
      Your code consisting of two lines are trying to access two different variables; “theMask” and “outline”.
      For this code to work, they will need to exist somehow in the system. You define these two variables by putting “instance names” on the relevant MovieClips.

      For example, we made the mask shape into a MovieClip by hitting F8 and naming it Mask. Now, that is the name of that MovieClip, but NOT its instance name.
      You can drag out a MovieClip on the stage and click it. Then you check the properties panel/view, and there you will find a field called instance name (at least it says so in a tooltip when mousing over it).

      Check the properties of your MovieClips, you should have one called “theMask” and one “outline”, without the quotes of course.

      I’ve sent a CS3 version of the tutorial to Ian (the editor) and the files will hopefully be updated soon. Then you should be able to check how it is done and hopefully straight out your questions!

      Good luck. Perseverance is key to success when you’re starting to learn this stuff.

      ( Reply )
    2. PG

      Ian Yates September 21st

      Source files have been updated, thanks Karl.

      ( Reply )
  27. PG

    Max Miller September 28th

    I keep getting this error:

    1120: Access of undefined property outline.

    Any ideas what I did wrong?

    ( Reply )
  28. PG

    Rob October 1st

    What would the code be for AS2? i’ve tried the code below
    but it doesn’t seem to work….

    theMask.cacheAsBitmap = true;

    outline.setMask(theMask);

    ( Reply )
  29. PG

    image masking October 4th

    I love the amount of details you gave in your instructions through this tutorial. Great example. Looking forward to more from you.

    ( Reply )
  30. PG

    Chris B October 21st

    nice tutorial. But I couldn’t get the mask to use the gradient for transparency no matter what steps I followed.

    Flash just doesn’t want to play nicely today :(

    ( Reply )
  31. PG

    Terry October 27th

    Was there any news on this CS3 version.

    Right now, I have a black rectangle that moves across my logo, outline and background.

    I didnt even START with the ‘bling’, and probably wont until I can get this bit to work, but yes, I am using CS3.

    ( Reply )
    1. PG

      Ian Yates October 28th

      You can download the source from here (or via the link at the top of the page). CS3 files are included.

      ( Reply )
  32. PG

    Scott Prock October 30th

    Any answer on the AS2 code ?

    I walked through the tutorial with my own design and it worked perfectly, but I am trying to do this on an already created file that was done with AS2, and it’s not working.

    Thanks … Scott

    ( Reply )
  33. PG

    Smashing Buzz October 31st

    thats really nice lightening effect on logo. helping with great idea for further implementation on my personal projects. thanks

    ( Reply )
  34. PG

    Rob November 9th

    I’m in the same boat as scott, works fine in AS3 but need an AS2 version for work.

    Can anyone help wth this?

    ( Reply )
  35. PG

    Himanshu Sharma November 16th

    hi I learn from this tutorial How can I mask a simpalel tecnic.
    I save time.
    From- Himanshu
    VNS(U.P.)

    ( Reply )
  36. PG

    Karl Macklin November 20th

    I rarely code any AS2 so I can’t really help you there, other than advise you to take the basic approach that I use in this tutorial and make sure you cache whatever you’re masking, plus the mask, ask bitmaps (if they’re not already).

    In AS2, a MovieClip also has the cacheAsBitmap property. A MovieClip also has setMask as a function which takes the desired mask MovieClip as parameter.
    Shouldn’t be hard to sort out the rest I think, just try it!

    ( Reply )
  37. PG

    Adam November 22nd

    Wow, thanks a bunch! And thanks for including the CS3 version! For people trying to create this effect without following the tutorial exactly, note that you can do everything right, but without applying the blur filter on the instance being masked, this effect will not work! I discovered this after about 3 hours of hair pulling.

    ( Reply )
  38. PG

    Rob November 24th

    Thanks Karl

    I did some digging after what you said and found the AS2 solution:

    maskee.cacheAsBitmap = true;
    maskMC.cacheAsBitmap = true;
    maskee.setMask(maskMC);

    You were right to cache everything and I have it working now. Also, I found the AS needs to be executed at the same time as the MCs appear.

    Rob

    ( Reply )
  39. PG

    EKLIPz December 17th

    Great Tutorial. Thanks. :)

    ( Reply )
  40. PG

    metu_yal December 17th

    thank you very much especially let me know about alpha gradient masking. i was about to be crazy while trying to achieve an alpha masking

    ( Reply )
  41. PG

    Bloggerzbible January 10th

    logo is beautiful

    ( Reply )
  42. PG

    saura January 27th

    reyrtyrtyrt

    ( Reply )
  1. Arrow
    Gravatar

    Your Name
    January 27th