Masking Advance


Read this thoroughly explained, detailed flash lesson and see how to create Elipse mask animation using the AS3 and some special flash tips and tricks. You can use this animation for some flash header or for some other flashcomponents. Using this lesson, you will also learn how to import any image into a flash stage, how to create instance name, how to linkage any object and much more!

Step 1

First, find any image which you like to use for this lesson.


Step 2

Create a new flash document. Press Ctrl+J key on the keyboard (Document Properties) and set the dimensions of your document as the dimensions of image. Select any color as background color. Set your Flash movie's frame rate to 44 and click ok.

Step 3

Call the current layer image. Double-click on its default name (Layer 1) to change it. Press Enter once you have typed in the new name!

Step 4

Choose now File > Import > Import to stage (Ctrl+R) and import any image into a flash stage. While the image is still selected, go to the Align Panel (Ctrl+K) and do the following:

1. Make sure that the Align/Distribute to Stage button is turned on,
2. Click on the Align horizontal center button and
3. Click the Align vertical center button.

Step 5

While the image is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.

Step 6

While the new made movie clip is still selected, go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this Movie Clip image_mc. See the picture below!

Step 7

Select the Oval Tool (O) and draw a elipse shape like it is shown on the picture below!

Step 8

While the elipse shape is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol. 

Step 9

Delete now elipse movie clip from the flash stage.

Step 10

Go now to the Flash Library, hit right click on elipse movie and choose Linkage. After that, for Class type MaskShape. See the picture below!

Step 11

Create a new layer above the layer image and name it action. Select the first frame of layer action and go to the action script panel (F9). Then, enter this code inside the actions panel:

var container:Sprite = new Sprite();


image_mc.mask = container;
addChild (container);

var timer = new Timer(40,15);
timer.addEventListener (TimerEvent.TIMER, createMaskShape);
timer.start ();

function createMaskShape (e:Event):void {

 var maskShape:MaskShape = new MaskShape();

 maskShape.scaleX = 0;
 maskShape.scaleY = 0;

 maskShape.x = Math.random() * stage.stageWidth;
 maskShape.y = Math.random() * stage.stageHeight;

 container.addChild (maskShape);

 maskShape.addEventListener (Event.ENTER_FRAME, animateMaskShape);

function animateMaskShape (e:Event):void { += 0.05; += 0.05;

We're done!



Taken from