I am working on a paintbrush application in AS2
Currently I am working with drawing a circle. I have a circle movieclip in library. Whenever users click and drag on the stage they can design a circle. I am using mouseDown, mouseMove and mouseUp event for this.
So for mousedown I am calculating the current x and y position
then for mouseMove the circle starts to grow depending upon the x and y position of mouse
Then for mouseUp I am deleting the mouseMove function, so that it stops drawing. This is working fine. But when I want to draw another object on the stage the mouseMove function does not work. I am confused on how to undelete the mouseMove function.
Here is my code:
_global.firstClickX;
_global.firstClickY;
_global.levelNo = 0;
_root.draw_mc.onMouseDown=function(){
drawCircle()
trace(levelNo)
}
_root.draw_mc.onMouseMove=function(){
moveCircle()
}
_root.draw_mc.onMouseUp=function(){
stopDrawing();
}
function drawCircle(){
_global.levelNo+=1;
_root.draw_mc.attachMovie("circle_mc", "circle_mc"+_global.levelNo,_global.levelNo);
_root.draw_mc["circle_mc"+_global.levelNo]._x =_root.draw_mc._xmouse;
_root.draw_mc["circle_mc"+_global.levelNo]._y =_root.draw_mc._ymouse;
_global.firstClickX =_root.draw_mc._xmouse;
_global.firstClickY = _root.draw_mc._ymouse;
_root.draw_mc["circle_mc"+_global.levelNo]._width = 1
_root.draw_mc["circle_mc"+_global.levelNo]._height = 1;
}
function moveCircle(){
_root.draw_mc["circle_mc"+_global.levelNo]._width = _root.draw_mc._xmouse - firstClickX
_root.draw_mc["circle_mc"+_global.levelNo]._height =_root.draw_mc._ymouse - firstClickY;
}
function stopDrawing(){
//delete _root.draw_mc.onMouseMove;
delete moveCircle;
}
Any help will be appreciated.
Thanks