1. Home
  2. Computing & Technology
  3. Animation

Deconstructing the Paint Application IV: The Oval Tool

By Adrien-Luc Sanders, About.com

2 of 4

Defining Mouse Behavior for Ovals on Mouse Movement

For the oval tool, we don’t really need to start drawing the moment that the mouse is depressed; we just need to remember that we already defined the location of [link url=http://animation.about.com/od/flashanimationtutorials/ss/paintapp2_7.htm]_root.linex and _root.liney[/url] in our first onClipEvent (mouseDown), and that will be pivotal in determining the behavior of the oval tool when the mouse moves and when it’s released. Just like the line tool, we want to create a single-pixel tracker inside a new empty movie clip that lets the user preview the size of the circle drawn when the mouse is clicked and dragged:
if (_root.isactive=="circle"){
_root.createEmptyMovieClip("ellipsetracker",2) ;
_root.ellipsetracker.lineStyle(1,_root.currentcolor,100) ;
_root.ellipsetracker.moveTo(_root.linex,(_root._ymouse+_root.liney)/2) ;
_root.ellipsetracker.curveTo(_root.linex, _root.liney,(_root._xmouse+_root.linex)/2,_root.liney ) ;
_root.ellipsetracker.curveTo(_root._xmouse, _root.liney,_root._xmouse, (_root._ymouse+_root.liney)/2 ) ;
_root.ellipsetracker.curveTo(_root._xmouse,_root._ymouse,(_root._xmouse+_root.linex)/2,_root._ymouse) ;
_root.ellipsetracker.curveTo(_root.linex, _root._ymouse, _root.linex,(_root.liney+_root._ymouse)/2 ) ;
}

This is placed inside the same onClipEvent (mouseMove) that contains the movement behavior for the brush tool and the line tool; the script checks to make sure that the value of _root.isactive is set to “circle” and then performs the actions set inside.

The format of curveTo is similar to that of lineTo, in that the size, color, and opacity of the curve drawn are set using lineStyle and the starting point must be set using moveTo. The rest, however, probably looks like Greek, so let’s dissect it.

Explore Animation
About.com Special Features

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

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. Deconstructing the Paint Application IV: The Oval Tool

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

All rights reserved.