Lastly, we just need to make the brush stop drawing when the mouse cursor is released:
onClipEvent (mouseUp) {
draw=false;
}
Yes, that really is all there is to it. Because the mouseMove event only works when draw=true, setting draw to [false] causes the conditions of the if statement not to validate, so it wont draw when the mouse is moved. draw wont be set back to true again until the mouse button is once more pressed.
That just about covers it. A few things to keep in mind:
All of my color, size, and opacity options are variables gathered from input text boxes, but they can also be set as hex codes in the format 0x000000 (for the color) or numeric values (0-255 for the line weight/size, 0-100 for the opacity).
Lines drawn and connected using the drawing API wont automatically fill; it instead creates a stroked outline of a shape that has to either be filled in manually or using ActionScript commands that well cover in the next lesson.
You should always enter the full path of your variables, such as _root.base.opac instead of just opac. Youll often be calling a variable set at the root level or even inside a movie clip from within another movie clip, and youll need to make sure that Flash knows where to look.
Dont be afraid to set up multiple movie clip controllers to the side of your main stage. Youre going to rack up several hundred lines of code in developing this application, and if separating them into multiple script containers helps you keep everything sorted and functioning properly, theres nothing wrong with it.
Good luck.