1. Home
  2. Computing & Technology
  3. Animation

Deconstructing the Paint Application II: The Brush Tool & the Flash Drawing API

By , About.com Guide

9 of 9

Defining Brush Behavior When the Mouse is Released

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 won’t draw when the mouse is moved. draw won’t 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 won’t automatically fill; it instead creates a stroked outline of a shape that has to either be filled in manually or using ActionScript commands that we’ll cover in the next lesson.

  • You should always enter the full path of your variables, such as _root.base.opac instead of just opac. You’ll often be calling a variable set at the root level or even inside a movie clip from within another movie clip, and you’ll need to make sure that Flash knows where to look.

  • Don’t be afraid to set up multiple movie clip controllers to the side of your main stage. You’re 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, there’s nothing wrong with it.
  • Good luck.

    Explore Animation
    About.com Special Features

    Holiday Central

    What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

    Family Tech Center

    Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

    1. Home
    2. Computing & Technology
    3. Animation
    4. Flash Animation Tutorials
    5. Deconstructing the Paint Application II: The Brush Tool and the Flash Drawing API

    ©2009 About.com, a part of The New York Times Company.

    All rights reserved.