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.
1 REPLY
Author
surferboy
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.![]()
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);
- 17 March 2009 04:43 AM
-
- Log in or join for free to make a comment.
Topic Categories


