benhg
11-20-2007, 12:40 AM
hi,
i am trying to make a line draw from the mouse when the button is held down, it seems to work but my problem is that it always seems to draw on the bottom layer. my code is inside of a movieclip that is on the main stage, inside this movie clip there are 2 other movieclips (one is a pencil image, the other is a notepad image). the line always draws underneath the notepad image, even though the notepad is on the bottom layer.
here is my code:
var drawing:Boolean;
graphics.lineStyle(1,0x000000);
drawing = false;
this.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing);
this.addEventListener(MouseEvent.MOUSE_MOVE, drawGo);
this.addEventListener(MouseEvent.MOUSE_UP, stopDrawing);
function startDrawing(event:MouseEvent):void {
graphics.moveTo( mouseX, mouseY);
drawing = true;
}
function drawGo(event:MouseEvent) {
if (drawing) {
graphics.lineTo(mouseX,mouseY);
}
}
function stopDrawing(event:MouseEvent) {
drawing = false;
}
So really all i need is to figure out how to make this draw on the top layer. i have stried using setChildIndex() but that didnt work.
And also can anyone tell me how to clear the drawing?
can anyone help?
Thanks
i am trying to make a line draw from the mouse when the button is held down, it seems to work but my problem is that it always seems to draw on the bottom layer. my code is inside of a movieclip that is on the main stage, inside this movie clip there are 2 other movieclips (one is a pencil image, the other is a notepad image). the line always draws underneath the notepad image, even though the notepad is on the bottom layer.
here is my code:
var drawing:Boolean;
graphics.lineStyle(1,0x000000);
drawing = false;
this.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing);
this.addEventListener(MouseEvent.MOUSE_MOVE, drawGo);
this.addEventListener(MouseEvent.MOUSE_UP, stopDrawing);
function startDrawing(event:MouseEvent):void {
graphics.moveTo( mouseX, mouseY);
drawing = true;
}
function drawGo(event:MouseEvent) {
if (drawing) {
graphics.lineTo(mouseX,mouseY);
}
}
function stopDrawing(event:MouseEvent) {
drawing = false;
}
So really all i need is to figure out how to make this draw on the top layer. i have stried using setChildIndex() but that didnt work.
And also can anyone tell me how to clear the drawing?
can anyone help?
Thanks