var x0 = 0;
var y0 = 0;
var x1 = 0;
var y1 = 0;
var count = 0;
this.lineStyle(0, 0x0000);
this.onMouseDown = function() {
this.x0 = this._xmouse;
this.y0 = this._ymouse;
this.count++;
this.moveTo(this.x0, this.y0);
};
this.onMouseUp = function() {
this.x1 = this._xmouse;
this.y1 = this._ymouse;
// *1
var width:Number = this.x1 - this.x0
// *2
var height:Number = -1 * (this.y1 - this.y0);
var rad:Number;
var deg:Number;
// *3
rad = Math.atan2(height, width);
// *4
if (rad > 0 and height < 0) {
rad += -Math.PI;
}
else if (rad < 0 and height > 0) {
rad += Math.PI;
}
// *5
deg = (rad * 180) / Math.PI;
this.lineTo(this.x1, this.y1);
this.createTextField('text' + this.count, this.count,
this.x0, this.y0, 100, 20);
this['text' + this.count].text = deg + '°';
this['text' + this.count].selectable = false;
trace(deg);
};
trackback for this entry URL:
http://blog.graffiti-web.org/mt/mt-tb.cgi/210