HW2002
12-22-2007, 10:45 AM
Hi,
I'm trying to draw dynamic mask but it is not working as supposed?
I can only get it to work this way, when you move the mouse it will draw white lines on the stage, after that you can click on the mouse to apply the lines on the mask? Why cannot I apply the mask and draw the lines dynamic?
Thanks for any help :)
public class Main extends Sprite {
private var child:Shape = new Shape();
private var masked:Sprite = new Sprite();
private var num:Number = 0;
public function Main():void {
addChild(child);
background.mask = masked;
addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
private function mouseMove(m:MouseEvent):void {
child.graphics.lineStyle(2, 0xFFFFFF);
child.graphics.lineTo(mouseX, mouseY);
}
private function mouseDown(m:MouseEvent):void {
masked.addChild(child);
}
}
I'm trying to draw dynamic mask but it is not working as supposed?
I can only get it to work this way, when you move the mouse it will draw white lines on the stage, after that you can click on the mouse to apply the lines on the mask? Why cannot I apply the mask and draw the lines dynamic?
Thanks for any help :)
public class Main extends Sprite {
private var child:Shape = new Shape();
private var masked:Sprite = new Sprite();
private var num:Number = 0;
public function Main():void {
addChild(child);
background.mask = masked;
addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
private function mouseMove(m:MouseEvent):void {
child.graphics.lineStyle(2, 0xFFFFFF);
child.graphics.lineTo(mouseX, mouseY);
}
private function mouseDown(m:MouseEvent):void {
masked.addChild(child);
}
}