Here's an AS1 way to do it, from the deep archives...
MovieClip.prototype.drawArrow = function(sp, ep, th, headL, headW, c) {
// sp, ep = startPoint, endPoint; (point objects, objects with xand y)
// th = line thickness
// headL = headLength, headW = headWidth
// c = color
this.lineStyle(th, c, 100);
this.moveTo(sp.x, sp.y);
this.lineTo(ep.x, ep.y);
this.arrowAngle = Math.atan2(ep.y-sp.y, ep.x-sp.x);
// value in Radians
if (headL>0 && headW>0) {
this.drawArrowHead(ep.x, ep.y, this.arrowAngle, headL, headW, c);
}
};
MovieClip.prototype.drawArrowHead = function(x, y, a, l, w, c) {
// x, y = reg.point of arrowhead
// a = angle
// l = length, w = width
// c = color
var halveWay = (w/180*Math.PI);
// value in Radians
var AX = l*Math.cos(a+halveWay);
var AY = l*Math.sin(a+halveWay);
var BX = l*Math.cos(a-halveWay);
var BY = l*Math.sin(a-halveWay);
this.moveTo(x, y);
this.beginFill(c, 100);
this.lineTo(x-AX, y-AY);
this.lineTo(x-BX, y-BY);
this.lineTo(x, y);
this.endFill();
};
// usage:
this.createEmptyMovieClip("arrow", 10);
this.arrow.drawArrow({x:100, y:100}, {x:400, y:100}, 1, 50, 10, 0x333333);
Jim Kremens
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com