1. Home
  2. Computing & Technology
  3. Animation

Deconstructing the Paint Application V: The RectangleTool

By Adrien-Luc Sanders, About.com

2 of 3

Behavior Defined on Mouse Movement

This is actually going to be fairly easy, as it combines techniques used with the Line Tool and techniques used with the Oval Tool. First we define what happens when the mouse moves, within the same onClipEvent that controls all other mouse movement functions while the mouse is down:
if (_root.isactive=="rectangle"){
_root.createEmptyMovieClip ("rectracker",2) ;
_root.rectracker.moveTo(_root.linex,_root.liney) ;
_root.rectracker.lineStyle(1,_root.currentcolor,100) ;
_root.rectracker.lineTo(_root.linex,_root._ymouse) ;
_root.rectracker.lineTo(_root.linex,_root.liney) ;
_root.rectracker.lineTo(_root._xmouse,_root.liney) ;
_root.rectracker.lineTo(_root._xmouse,_root._ymouse) ;
_root.rectracker.lineTo(_root.linex,_root._ymouse) ;
}

This is another "tracker": an outline that disappears once the mouse is released, just letting the user see the size and shape on a new movie clip called rectracker. This uses lineTo like the Line Tool, but like the Oval Tool it connects those lines to create a closed shape by starting at one point and the connecting the four points between the starting point and the ending position of the mouse to create a closed rectangle.

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 V: The RectangleTool

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

All rights reserved.