1. Home
  2. Computing & Technology
  3. Animation

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

By , About.com Guide

4 of 9

Activating the Brush Cursor Based on Cursor Location: The Code

Let’s move on to controlling the behavior and appearance of the brush cursor. This is a pretty long chunk of code, so let’s look at it first, then break it down in the next step. (Hey, I’ve got character limits here.)
onClipEvent (enterFrame) {
mouseypos=_root._ymouse;
mousexpos=_root._xmouse;
if (mouseypos>=20&&mouseypos<=532&&mousexpos>=29&&mousexpos<=666) {
if (_root.isactive=="brush"){
if (_root.base.palette._visible==true||_root.base.helptabs._visible==true){
Mouse.show() ;
}
else {
_root.brushcursor._x=_root._xmouse;
_root.brushcursor._y=_root._ymouse;
_root.brushcursor._width=_root.base.bsize;
_root.brushcursor._height=_root.base.bsize;
cursorcolor = new Color(_root.brushcursor.cursorbrush) ;
cursorcolor.setRGB
(_root.currentcolor) ;
_root.brushcursor.cursorbrush._alpha=_root.base.opac;
Mouse.hide() ;
}
}
else {
_root.brushcursor._x=-100;
_root.brushcursor._y=-100;
Mouse.show() ;
}
}

These actions are assigned to a controller – something I like to use rather often; it’s just a movie clip to the side of the visible area of the stage with no other function than for me to assign actions to it to control the behavior of other movie clips. They tend to turn into my storehouse of ActionScripts and let me organize them a bit better.

All of this is done inside an onEnterFrame clip event assigned to the controller.

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.