_root.createEmptyMovieClip("myLine", 0); // create blank movie to draw on
function moveroutine() // this moves the pen to follow the mouse
{
PenItem._x = _xmouse;
PenItem._y = _ymouse - PenItem._height;
}
function drawroutine() // this draws the line when the button is pressed
{
myLine.lineTo(_xmouse, _ymouse);
moveroutine();
}
_root.onMouseMove = moveroutine; // initially we only move the pen
_root.onMouseDown = function() // when the user clicks the button
{
myLine.moveTo(_xmouse, _ymouse);
myLine.lineStyle(2, 0xff0000, 100);
_root.onMouseMove = drawroutine;
}
_root.onMouseUp = function() // when the button is released
{
_root.onMouseMove = moveroutine;
}
NOTE: You have to target Flash Player 6 or above.
Download source project t1042.zip (4 kb)