1. Home
  2. Computing & Technology
  3. Animation

Deconstructing the Paint Application IV: The Oval Tool

By , About.com Guide

4 of 4

Filling in the Ellipse

Is your head hurting yet? Mine is. curveTo is one of the hardest parts of the Flash Drawing API to understand, but once you get the hang of it it’s quite useful and quite easy.

Moving on: just as with the line tool’s tracker, once the mouse button is released we’re going to want to use clear() to clear the oval tool’s tracker and draw the final shape using the user-specified color and opacity, this time with a stroke of 0:

if(_root.isactive=="circle"){
_root.ellipsetracker.moveTo(_root.linex,(_root.liney+_root._ymouse)/2) ;
_root.layer.lineStyle(0,_root.currentcolor,0) ;
_root.layer.moveTo(_root.linex,(_root._ymouse+_root.liney)/2) ;
_root.layer.beginFill(_root.currentcolor,_root.base.opac) ;
_root.layer.curveTo(_root.linex, _root.liney,(_root._xmouse+_root.linex)/2,_root.liney ) ;
_root.layer.curveTo(_root._xmouse, _root.liney,_root._xmouse,
(_root._ymouse+_root.liney)/2 ) ;
_root.layer.curveTo(_root._xmouse,_root._ymouse,(_root._xmouse+_root.linex)/2,_root.
_ymouse) ;
_root.layer.curveTo(_root.linex, _root._ymouse,
_root.linex,(_root.liney+_root._ymouse)/2 ) ;
_root.layer.endFill() ;
_root.ellipsetracker.clear() ;
}

This uses the exact same coordinate as the tracker when the mouse is released, drawing the oval at exact size and shape specified by the user but using only a solid fill. You’ll notice two new commands in bold: beginFill and endFill. The first tells Flash that it needs to fill a closed shape that will be defined by the API commands following the beginFill command, with the fill set at the color and opacity defined inside (either by variable or hex and numeric values). The latter tells Flash when it should stop filling, and nothing else. Both must be included or it won’t work.

Explore Animation
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, 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 IV: The Oval Tool

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

All rights reserved.