ActionScript 3.0 – Draw Line

(Move your mouse over the image above if you’re feeling violent).

Download Source Files

In AS 3.0, to draw a line that continually changes, add the following code in an ENTER_FRAME:

//remove graphic to remove previously drawn line each time
container.graphics.clear();
//define line width in pixels
container.graphics.lineStyle(15);
//move the drawing pen. Mace X and Y are dynamic positions
container.graphics.moveTo(mace.x, mace.y);
//draw lines from the start (above) to the mouse position
container.graphics.lineTo(mouseX, mouseY);

error

Enjoy this blog? Please spread the word :)