In this tutorial, we'll create an animated mask image revealer, which will involve movie clips, masks and ActionScript 3.
Final Result Preview
Below is the final result we will be working towards.
Step 1 - Brief Overview
We'll be creating the above effect, but without the "click replay" feature. Here is an overview of what we'll do. There will be two layers. One will hold the actions and the other will contain the image. We'll also create an animated Movie Clip which will be added to a mask at run-time. The purpose of the animated Movie Clip is to reveal the image bit by bit.
I'm assuming you already have a basic understanding of Flash and ActionScript 3. However, I'll still try to keep each step as clear as possible.
Step 2
Create a new ActionScript 3 document. Set the Stage size to 600 x 420px and 24 FPS. I've chosen this size since the image I'll be using will fit nicely within these dimensions.

Step 3
Rename the first layer to "image" and then import the image. I've imported an image of a beach and center aligned it to the stage.

Step 4
Now select the image and convert it to a Movie Clip symbol. I've named it "beach", but it can really be anything. Make sure the registration point is at the top left corner.

Step 5
Give the new image Movie Clip an instance name of "imageToReveal_mc". Lock that layer since we won't change it anymore.

Note: I've ended the name with "_mc". This is handy if you want automatic code hinting while in the Actions panel.
Step 6
Let's do a bit of animation now. Create a new symbol and give it a name "circle animation". Select "Movie Clip" as the type.

Step 7
You should now be within the "circle animation" timeline. First rename the layer to "animation" and then create a 80 x 80px circle on the stage. Center align it.

Step 8
Select the circle and convert it into a symbol (F8). Name it "circle" and select "Graphic" as the type. Make sure the registration point is "center".

Step 9
Select the graphic circle and apply a simple motion tween. The duration will be 14 frames. Make sure the circle has a scale of 1% on frame 1 and 100% on frame 14. You can adjust the position/scale/rotation of the circle anyway you like between the frames. I've only scaled mine.

Step 10
Now create a new layer in the Movie Clip called "actions". Insert a key frame at the very last frame (14). Open the Actions panel and add a stop action. This stops the animation from looping.

Step 11
Once that's done, go to the Library Panel, right click "circle animation" and select "Properties...". Make sure you're in the "Advanced" view. Check "Export for ActionScript" - "Export in frame 1" should automatically be checked. For the class, enter "CircleAnimation" and leave the base class as "flash.display.MovieClip".

Step 12 - Check point
Now go back to the main timeline and make sure that just the "image" layer is on the stage. The new "circle animation" you created shouldn't be on the stage, it should only exist in the library.
Step 13
Create a new layer called "actions" and lock it. Select the first frame for that layer and go into the Actions panel.

Note: Normally I like to put my "actions" layer at the top so it's easy to find.
Step 14
First, create a mask for the image. Then add it to the stage and assign the mask to the image Movie Clip.

Step 15
Now we'll create 4 variables: xPos, yPos, spacingX, and spacingY. "xPos" and "yPos" will be used to position the new CircleAnimation instances. "spacingX" and "spacingY" is the spacing between each CircleAnimation instance along the x and y axis.

Step 16
Because we want to add CircleAnimation instances into the mask one by one, we'll use a Timer to call a function repeatedly. The function "revealImage" will be called every 30 milliseconds. In order to start the Timer you also need to call the "start" method.

Note: I'd suggest you use the uncommented addEventListener since it can help with memory management if you ever forget to remove unused listeners. The fifth parameter (true) refers to "weak reference", which by default is set to "false". For more information about "weak reference", have a look at this blog post.
Step 17
Let's create the "revealImage" function now. Make sure it has a parameter of type "TimerEvent".

Step 18
Now create a new CircleAnimation instance and position it based on the "xPos" and "yPos". Then add it into the mask.

Step 19
Currently all the CircleAnimation instances stack up on top of each other since "xPos" and "yPos" are always the same. What we want is to have the instances appear left to right and top to bottom, so we need to make sure that we increment the "xPos" by "spaceX". The same goes for "yPos" by "spaceY", however "yPos" should only increment when "xPos" exceeds the maximum x boundary. When that happens, "xPos" also needs to reset back to the left.

Step 20
If you test your movie now, it should reveal the image like the final effect. There is one important thing that you may not have noticed; CircleAnimation instances are still being created even after the image is revealed. This is because the "createChildTimer" event listener is never removed. We need to check to see if "yPos" has exceeded the maximum y boundary and if so, remove the "createChildTimer" event listener.

Step 21 - Final code
By the way, "imageToReveal_mc.x + imageToReveal_mc.width + spacingX" and "imageToReveal_mc.y + imageToReveal_mc.height + spacingY" never change thus I've stored them into the variables "maxXPos" and "maxYPos".
Your final code in the Actions panel should look something like this...
var maskImg:MovieClip = new MovieClip();
addChild(maskImg);
imageToReveal_mc.mask = maskImg;
var xPos:Number = imageToReveal_mc.x;
var yPos:Number = imageToReveal_mc.y;
var spacingX:Number = 50;
var spacingY:Number = 50;
var createChildTimer:Timer = new Timer(30);
// createChildTimer.addEventListener(TimerEvent.TIMER, revealImage);
createChildTimer.addEventListener(TimerEvent.TIMER, revealImage, false, 0, true);
createChildTimer.start();
var maxXPos:Number = imageToReveal_mc.x + imageToReveal_mc.width + spacingX;
var maxYPos:Number = imageToReveal_mc.y + imageToReveal_mc.height + spacingY;
function revealImage(evt:TimerEvent):void {
var ca:CircleAnimation = new CircleAnimation();
ca.x = xPos;
ca.y = yPos;
maskImg.addChild(ca);
xPos += spacingX;
if (xPos > maxXPos) {
xPos = imageToReveal_mc.x;
yPos += spacingY;
}
if (yPos > maxYPos) {
createChildTimer.removeEventListener(TimerEvent.TIMER, revealImage);
}
}
Step 22 - Optional row by row
By using a bit of recursion, we can change the effect so that it reveals the image row by row.
var maskImg:MovieClip = new MovieClip();
addChild(maskImg);
imageToReveal_mc.mask = maskImg;
var xPos:Number = imageToReveal_mc.x;
var yPos:Number = imageToReveal_mc.y;
var spacingX:Number = 50;
var spacingY:Number = 50;
var createChildTimer:Timer = new Timer(120);
// createChildTimer.addEventListener(TimerEvent.TIMER, revealImage);
createChildTimer.addEventListener(TimerEvent.TIMER, revealImage, false, 0, true);
createChildTimer.start();
var maxXPos:Number = imageToReveal_mc.x + imageToReveal_mc.width + spacingX;
var maxYPos:Number = imageToReveal_mc.y + imageToReveal_mc.height + spacingY;
function revealImage(evt:TimerEvent):void {
var ca:CircleAnimation = new CircleAnimation();
ca.x = xPos;
ca.y = yPos;
maskImg.addChild(ca);
xPos += spacingX;
if (xPos > maxXPos) {
xPos = imageToReveal_mc.x;
yPos += spacingY;
} else {
revealImage(evt);
}
if (yPos > maxYPos) {
createChildTimer.removeEventListener(TimerEvent.TIMER, revealImage);
}
}
Step 23 - Optional column by column
Here is a column by column version. Most of the x and y variables/properties have swapped positions.
var maskImg:MovieClip = new MovieClip();
addChild(maskImg);
imageToReveal_mc.mask = maskImg;
var xPos:Number = imageToReveal_mc.x;
var yPos:Number = imageToReveal_mc.y;
var spacingX:Number = 50;
var spacingY:Number = 50;
var createChildTimer:Timer = new Timer(120);
// createChildTimer.addEventListener(TimerEvent.TIMER, revealImage);
createChildTimer.addEventListener(TimerEvent.TIMER, revealImage, false, 0, true);
createChildTimer.start();
var maxXPos:Number = imageToReveal_mc.x + imageToReveal_mc.width + spacingX;
var maxYPos:Number = imageToReveal_mc.y + imageToReveal_mc.height + spacingY;
function revealImage(evt:TimerEvent):void {
var ca:CircleAnimation = new CircleAnimation();
ca.x = xPos;
ca.y = yPos;
maskImg.addChild(ca);
yPos += spacingY;
if (yPos > maxYPos) {
yPos = imageToReveal_mc.y;
xPos += spacingX;
} else {
revealImage(evt);
}
if (xPos > maxXPos) {
createChildTimer.removeEventListener(TimerEvent.TIMER, revealImage);
}
}
Conclusion
There are many other things you can change in order to get different revealing effects such as the shape used in the animation, transformations within the animation, Timer speed, etc.
Thanks for viewing this tutorial and I hope you enjoyed it.














User Comments
( ADD YOURS )Abdoo March 28th
Cool Thanks
( )AnDi March 28th
Nice effect, couldnt wait for Flashtuts+
( )AmDworks March 28th
Nice tutorial !
. Thanks
( )Sirwan March 28th
nice.
reminds me of microsoft’s PowerPoint though.
( )Kwitt March 28th
Cool tutorial but why not display code as text instead of images?
( )See how nettuts is doing it…
kopcik March 29th
I suposted that is because now you have to rewrite the code so you are forced to learn it instead of copy paste method. You know what i mean?
( )btw: good tutorial, i should try it
TNk March 30th
As text would be great still if kopcik want to write it step by step
will add more usability. I only want to save my flash dev time i dont want to become one.
great tutotial looking forward for more ^^
( )Ian Yates April 3rd
Consider it done
( )Daniel Correia March 28th
Didn’t work. I probably did something wrong because my actions window seems to eat some letters, I mean, the letters are there but they’re partially invisible. Don’t know why this happens or how I can solve this.
( )Julius March 28th
Very Cool!
( )samBrown March 28th
nice effect and easy to mod into other masking behavior – thanks!
( )Clever21 March 28th
That’s so cool, I love FLASHTUTS
( )2tone March 28th
nice effect
( )Tim March 28th
You should use a tweening engine such as TweenMax and create the circle directly in AS3 with drawCircle : it will be much more customizable, faster to create, and smoother to run. And you’ll even be able to randomize the animation by tweaking some variable for size, speed, position, direction, etc…
( )Richard S Davies March 30th
Do you know of a tutorial using this method? I’ve been trying out GreenSock, and would like to see the differences in code with this method.
( )lawrence77 March 28th
thanks mate!
( )lawrence77 March 28th
Micheal Chen i found this kinda effects in your website also, but there it is rectangle! (something remembers this)
( )I like this effect!
sriganesh March 29th
so lawrence you also wathching this site huh
Phil March 28th
Nice Tutorial
( )yamaniac March 28th
nice tut!!! But i din find the time to type all the code and figure out… Tnx
( )macias March 28th
yep.. this one is better then previous tut
( )Clemente G March 28th
Nice one, I agree with one of the above posts, a tweening engine can keep this fully AS3 or possibly the annoying Tween Class that comes with Flash.
( )Ernest March 28th
Why U didn’t save this as CS3… source files are only for CS4 :F !?
( )Billy March 28th
awesome sauce on 1337 bix
( )José Carlos March 28th
Very good,
What about
c4d.tutsplus.com
Thanks
( )Reg. March 29th
Nice and usefull
( )Jordan March 29th
Nice tutorial, thanks! Like the above posters, I think a tweening engine would be cool to use (such as Tweener), but this is still awesome. Looking forward to more tuts!
( )salvador March 29th
Hello, I should like new post where you use after effect and flash for using at web
( )André March 29th
Nice, but you should use document class and classes instead of using timeline for this work, and should use actionscript instead of animation… would be very faster, and with classes in .as instead of timeline, would be very more usefull and easyer to modify something later. but nice work, congratulations, maybe if i can i will post some stuffs like using after effects with FLASH, and how to create a DeepLink engine, or how to use one of existing…
( )cyberstar March 29th
Nice. It’s really good to see source files are available, because in Flash a video, or well-written tuts sometimes are not enough…the source files really help.
( )Richard S Davies March 30th
Really good tut, pity the text isn’t selectable, maybe use a text box instead of an image like NetTuts?
( )Carlos Pinho March 30th
Nice effect. Good for page transitions and slideshow interfaces.
( )Chatton March 30th
you posted cs4 .fla files :/
nice tut btw!
( )Rafael R.P (Raff) March 30th
Can u convert to CS3 files please?
Thx great tutorial!
( )Diego SA March 30th
Awesome!
( )Flash Framer March 30th
Very unique! I can’t wait to use this effect in one of my projects.
( )ViniMan March 30th
This is a message to the editor of Flashtuts+, ask people to put their codes in text. Better for google, easier to copy+paste,etc.
( )Ian Yates March 30th
Don’t worry, it’s something we have every intention of doing from now on (with the exception of screencasts) – get those copy+paste fingers at the ready…
( )ViniMan April 1st
Awesome!
Michael Chen March 30th
Hi everyone,
Thank you for the comments.
A few people have mentioned using a Tweening engine for the circle animation, which is also a feasible alternative.
I’ll definitely incorporate the ’syntax highlighter’ in the future.
For all the CS3 users, I’ve resaved another version to CS3 and sent it to the Editor.
Finally thanks to everyone who has taken the time to look through my tutorial.
regards,
( )Mike
Jake Scott March 30th
Nice photo of St Clair, I recognise that beach any day!!
( )Dave Poon March 30th
Very nice effect, looking forward to other excellent tutorials from you guys, thanks!
( )Design Jar March 31st
Simple effect but really looks really effective.
Would look great in a transition on a company portfolio.
( )thelastpulse April 1st
I can’t express the amount of love I have for envato for making this website and also for this tutorial
( )Lys April 3rd
good tutorial! i will try it.
( )Bruno April 3rd
Very Nice effect !!
( )ac April 3rd
This is good. What about adding a new contact to the XML with a form?
( )Joao Aliano April 13th
It would be very very nice to see this mask fill in randomly. How would you do it?
If you make a grid of 5 rows by 10 columns, let’s say, you’d have spacingX and Y multiply by a random of 5 and 10 until you’d loop 50 times (5×10)
But how you’d prevent stacking (repeated numbers & masks on top of each other)
( )surender April 14th
very nice
( )Joe April 16th
I like!
( )CgBaran Tuts April 27th
Great tutorial thanks
( )sudaka May 12th
Hello MAster …. thanks very much for this excellent tutorial ….
one QUESTION ?????
IF I WOULD LIKE TO DO AN OTHER OPTIONAL
————DIAGONAL by DIAGONAL—————–
maybe you can help me…please
SUDAKA
( )Zura June 24th
woow! I found best site!!
Great thanks.. Good tutorials…
( )Simone June 25th
I’d like to insert other animation after this. How do it? What actions I must add?
Thank you
( )Lee Regan October 13th
Does anyone know a way to get the effect to go from the center out. Kind of like a ripple on the water.
( )