1. Home
  2. Computing & Technology
  3. Animation

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

By , About.com Guide

5 of 9

Activating the Brush Cursor Based on Cursor Location: The Breakdown

The script assigned to this particular controller does four things: every time that the movie clip enters the frame, or twelve times per second, it checks the x and y positions of the mouse and updates the values of variables mouseypos and mousexpos to reflect.

Then it uses an if statement to check and see if those values are within a certain range – no less than a certain amount and no greater than another amount. What this is doing is checking to make sure that the mouse cursor is inside a certain area, defined by the pixel coordinates of the corners of the visible drawing area. When the mouse is inside the visible drawing area, we want to hide the mouse cursor and instead display the brush cursor movie clip that we made – unless the help file or color palette are visible, as both overlap the main canvas area.

That’s what the next if statement tests for, using an if/else statement. If either is visible, then Mouse.show() displays the mouse. In all other situations, however, the else statement does the following:

  • Moves the brush cursor movie clip’s x and y positions to the same place as the mouse cursor;

  • Sets the width and height of the brush cursor so that the diameter reflect pixel value bsize, which is a user-entered value gathered from an input text box and defining the size of the brush;

  • creates a new Color function and uses setRGB to change the color of the fill of the movie clip nested inside the brush cursor clip;

  • Sets the opacity of the movie clip’s fill to reflect another user-entered value;

  • Hides the mouse.
  • Lastly, another else statement linked to the first if statement says that if all of those conditions aren’t met, the brush cursor should be moved to an area off the visible stage, and makes the mouse cursor visible again.

    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.