Image Mask Eraser

February 6, 2009 by: smonte

This a very easy and quick tutorial. You’ll learn how to create an image mask eraser.

Setting up the environment

1. Import an image you want to use.

2. Convert the image into a movie clip (name it whatever you want).

3. Give it an instance name of “imageMC”.

Moving to ActionScript

4. Create an actions layer and type the following.

//This container contains all the mask graphics
var container:Sprite = new Sprite();
 
addChild (container);
 
//Set the container to be the image's mask
imageMC.mask = container;
 
//Set the starting point
container.graphics.moveTo (mouseX, mouseY);
 
addEventListener (Event.ENTER_FRAME, enterFrameHandler);
 
/*Draw a new rectangle in each frame and add it onto the container NOTE: you can use all kinds of shapes, not just rectangles! */
function enterFrameHandler (e:Event):void {
        container.graphics.beginFill(0xff00ff);
        container.graphics.drawRect(mouseX-50, mouseY-50, 100, 100);
        container.graphics.endFill();
}
 
Mouse.hide();

5. You are done, test your movie!

  • Digg
  • Sphinn
  • del.icio.us
  • Mixx

Related tutorials:

  1. Image Mask Animation
  2. Random Mask Circles on Image
  3. Mask Animation with ActionScript 3
  4. Shooting Masks via ActionScript 3
  5. Animated Spiral with ActionScript 3



Filed under: ActionScript 3 Advanced
Tags:

Comments

2 Responses to “Image Mask Eraser”
  1. Kayleigh says:

    This helped me out a lot thanks!

    Reply
  2. Suess says:

    Wow! That’s amazing! TOTALLY what i was looking fooor 0_0 thaaaaaaaaanks

    Reply