|
|
|
#1 |
|
Junior Member
Join Date: Feb 2004
Posts: 3
|
erease with cursor
I have a flash movie in which I want to allow the user to either erase a layer (using their mouse) to reveal the layer underneath, or to have the mouse draw a mask, to reveal the layer underneath.
Is one method easier than the other? Any good samples out there that will show how to simply do that? |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
I don't think there's anyway to dynamically erase in actionscript, but
creating a mask which reveals the layer underneath is doable. Here's how. Let's say you've already created a mask movie clip called myMask. Basically you would setup the mask movie to listen to mouse events: Code:
Mouse.addListener(myMask); to draw at the current mouse position when the mouse is moved, and the button is down... Code:
myMask.onMouseDown = function()
{
this.isErasing = true;
}
myMask.onMouseDown = function()
{
this.isErasing = false;
}
myMask.onMouseMove = function()
{
if (! this.isErasing)
return;
var mx = this._xmouse;
var my = this._ymouse;
// Draw something at mx,my.
// for a mask it must be a fill,
// not just lines.
// it will look nicer if you draw a circle using curveTo, but will also be slower...
var eWidth = 10; // radius of eraser
this.moveTo(mx-eWidth,my-eWidth);
this.beginFill(0,100);
this.lineTo(mx+eWidth,my-eWidth);
this.lineTo(mx+eWidth,my+eWidth);
this.lineTo(mx-eWidth,my+eWidth);
this.lineTo(mx-eWidth,my-eWidth);
this.endFill();
}
So it would probably be good to spend some time finding a way to optimize your eraser to draw fewer boxes... |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Oct 2002
Posts: 2
|
I tried this - but I am afraid that I am struggelling. I guess I am not putting the code in the right place??
Last edited by webwasp; 07-05-2005 at 04:30 AM. |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Mar 2006
Location: Serbia
Posts: 29
|
I can't get it work too....
|
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|