This class simply create a line using Graphics class lineTo and moveTo methods hope this will help someone
package
{
import flash.display.Graphics;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
/**
* ...
* @author Jeet Chauhan
*/
public class drawLine extends Sprite
{
// variable to hold graphics class instanve
private var g:Graphics;
public function drawLine():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
g = graphics
// this will set line thickness from 1 to 4 and a random color
g.lineStyle(int(Math.random() * 3) + 1, Math.random() * 0xff0000);
// this will moves the current drawing position to (50,50)
g.moveTo(50, 50);
draw();
}
private function draw():void
{
//Draws a line from the current drawing position to (500, 500).
g.lineTo(500, 500);
}
}
}