Re: how to create a line with pointed head
Hi, add this function after drawing the line
public function createArrow():void
{
var angle:Number = Math.atan2(getY2()-getY1(), getX2()-getX1());
graphics.lineTo(getX2()-arrowHeight*Math.cos(angle)-arrowWidth*Math.sin(angle),
getY2()-arrowHeight*Math.sin(angle)+arrowWidth*Math.cos(an gle));
graphics.lineTo(getX2(), getY2());
graphics.lineTo(getX2()-arrowHeight*Math.cos(angle)+arrowWidth*Math.sin(an gle),
getY2()-arrowHeight*Math.sin(angle)-arrowWidth*Math.cos(angle));
}
getX1(), getY1(), getx2(), getY2() are the start and end points of the line
Hope this will work for you.
|