1. Home
  2. Computing & Technology
  3. Animation

Deconstructing the Paint Application III: The Line Tool

By , About.com Guide

3 of 4

Drawing the Line on Mouse Release

Now for an addition to the onClipEvent (mouseUp) that defined the ending behavior for the brush:
if (_root.isactive=="line") {
_root.drawing.lineTo(_root._xmouse,_root._ymouse) ;
_root.linetracker.clear() ;
}

This reverts back to the movie clip drawing that we first set up to hold all of our painted shapes, and tells Flash that when the user finally lets go of the mouse, to fill in a line from that preset starting point to the current x and y coordinates of the mouse – this time on the drawing movie clip, with attributes already defined by the default lineStyle command used on mouseDown (with the opacity, color, and size reflecting current user selections).

But we’ve added on something completely different: _root.linetracker.clear() ;. You can already figure out what this does; it clears the movie clip that it’s assigned to of everything drawn on-stage since the movie loaded. This doesn’t work for things that were already created on-stage before the movie was published, however. All it does is remove the tracker that we’d created so that there wouldn’t be double lines overlapping.

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 III: The Line Tool

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

All rights reserved.