Ultrashock Forums > Flash > ActionScript
eraser tool in as3

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
eraser tool in as3
Old 2009-03-16

Hi.
I have a MC used as a mask. Now i want to erase parts of the mask dynamicly like the eraser tool in photoshop. Any ideas how to do that whith actionscript(as3)?
To draw a mask(lineTo) is no problem but to do the opposit seems to bee tricky.
postbit arrow 1 comment | 1610 views postbit arrow Reply: with Quote   
Registered User
surferboy is offline
seperator
Posts: 3
2002-08-15
Age: 30
surferboy lives in Sweden
seperator

Ultrashock Member Comments:
surferboy surferboy is offline surferboy lives in Sweden 2009-03-16 #2 Old  
Okay i found a way to do it.
This creates a 100x 100 circle to use to like the easertool i photoshop.
This way you can set the b(see code) as a mask and use it as inverted mask.

Code:
eraseableMc = new MovieClip();

eraseableMc .graphics.beginFill(0x000000, 1);
eraseableMc .graphics.drawRect(0, 0, 800, 600);
eraseableMc .graphics.endFill();

myBitmapData = new BitmapData(800, 600, true, 0x00000000);
//Copy the eraseableMc to bitMapData to be able to modify data. I do not add
//eraseableMc  to the stage.
myBitmapData.draw(eraseableMc , new Matrix(), null, BlendMode.NORMAL);
b = new Bitmap(myBitmapData);
addChild(b);
b.cacheAsBitmap = true;


// ... this code goes on a mousemove event or whatever you want to 
//use to control the erase.  
eraserClip = new Sprite();
eraserClip.graphics.beginFill(0xffffff, 1);					
eraserClip.graphics.drawEllipse(mouseX, mouseY, 100, 100);
myBitmapData.draw(eraserClip, new Matrix(), null, BlendMode.ERASE);
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: