Using a Switch to control drawing function

Hello all,

I need to create a specific drawing sequence that uses multple clicks to arrive at a certain shape.

Basically, I need the user to be able to draw a pie wedge over a bitmap image. The actual drawiing is not the problem right now, what I am struggling with is how to control the action based on how many times the person has clicked.

On the very first click, a temporary line is drawn from the center of the image, and the user can move the mouse around to get the first line where they want.

They click again and the temp line is cleared and the final line is put in place. Then, as they move the mouse off that last end point, I need a new temporary line to automatically generate (this is the second straight side of the wedge). They click a final time and that line locks in place and the wedge completes.

Now, the problem I have is that I am using a switch statement to test the clicks. When the routine starts I’ve got the var _root.c = 0. Here’s the switch:

[AS]switch (_root.c) {
case 0 :
_root.canvasArc.onMouseUp = drawFirstLine;
break;
case 1 :
_root.canvasArc.onMouseUp = drawSecondLine;
break;
}[/AS]

In the drawFirstLine function I’ve got this going on (I just copied the relevant parts):

[AS]this.onMouseMove = function() {
tempLine.clear();
//here’s the line style for the temporary line
tempLine.lineStyle(2, 0xE6E6E6, 50);
tempLine.moveTo(xPos, yPos);
point2._x = _xmouse;
point2._y = _ymouse;
tempLine.lineTo(_xmouse, _ymouse);
};
this.onMouseUp = function() {
tempLine.clear();
delete this.onMouseMove;
point1._visible = point2._visible=false;
line.lineStyle(3, 0xF7F742, 100);
line.lineTo(_xmouse, _ymouse);
delete this.onMouseUp;
ax = _xmouse;
ay = _ymouse;
line.moveTo(200, 200);
_root.c++;
};[/AS]

As you can see I am incrementing _root.c at the end of this. This part works fine (I verified that it is making _root.c = 1), but it seems that by breaking out of the switch statement, it doesn’t go back and check anything again, so my case 1 never gets read and the rest of the process can’t happen. Any ideas? I tried an if statement and even looped through that with setInterval but that doesn’t seem to work either. Is there just a smarter way to do this?

:puzzle:

Man, I don’t know what I would do without you. :toad:

Here is an animated GIF of what would happen:

The user would be able to repeat this process as many times as they want on each image (but probably no more than 6 times max).

I should also mention that while this is tricky enough, the user could theoretically need to create an arc that is up to 359 degrees. So if they continued moving the mouse around in a clockwise fashion the “wedge” would continue to grow into an almost complete circle…