Tutorials, extensions, and source files for ActionScript, Flash, and other Adobe products.

 

senocular.com ActionScript Library

arrowTo.as

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
MovieClip.prototype.arrowTo = function(x1,y1, x2,y2, fill, size, spread){
	var my = arguments.callee;
	var angle = Math.atan2(y2-y1, x2-x1);
	if (!fill) fill = my.defaultFill;
	if (!size) size = my.defaultSize;
	if (!spread) spread = my.defaultSpread;
	this.moveTo(x1, y1);
	this.beginFill.apply(this, fill);
	this.lineTo(x2, y2);
	this.lineTo(x2-Math.cos(angle+spread)*size, y2-Math.sin(angle+spread)*size);
	this.lineTo(x2-Math.cos(angle-spread)*size, y2-Math.sin(angle-spread)*size);
	this.lineTo(x2, y2);
	this.endFill();
}
MovieClip.prototype.arrowTo.defaultFill = [0,100];
MovieClip.prototype.arrowTo.defaultSize = 20;
MovieClip.prototype.arrowTo.defaultSpread = .3;