var x0:Number = zb_mc._x;
var y0:Number = zb_mc._y;
var x_d:Number = zb_mc._width/16;
var y_d:Number = zb_mc._height/16;
var a_array:Array = new Array();
var b_array:Array = new Array();
var i:Number = 0;
var j:Number = 0;
//计算向量角度的函数:
function jd(x1:Number, y1:Number, x2:Number, y2:Number) {
var d:Number = Math.sqrt(Math.pow(x2-x1, 2)+Math.pow(y2-y1, 2));
var jiaodu:Number = Math.abs(Math.acos((x2-x1)/d)*180/(Math.PI));
if (y1>y2 && x1y2 && x2x2) {
return 90+jiaodu;
} else if (y1y2 && x1 == x2) {
return 90-jiaodu;
} else if (y1x2) {
return 90-jiaodu;
}
}
//
function xl_hs(x1:Number, y1:Number, x2:Number, y2:Number):Void {
_root.lineStyle(1, 0x0000ff, 100);
_root.moveTo(x0+x1*x_d, y0-y1*y_d);
_root.lineTo(x0+x2*x_d, y0-y2*y_d);
_root.attachMovie("dot", "dot"+j, j);
_root["dot"+j]._rotation = jd(x0, y0, x0+x2*x_d, y0-y2*y_d);
_root["dot"+j]._x = x0+x2*x_d;
_root["dot"+j]._y = y0-y2*y_d;
_root.createTextField("t"+j, 10+j, x0+x2*x_d, y0-y2*y_d, 60, 30);
if (!jiaf.selected && !jianf.selected) {
_root["t"+j].text = "("+a_array[i]+","+b_array[i]+")";
} else if (jiaf.selected) {
_root["t"+j].text = "("+(a_array[i]+a_array[i-1])+","+(b_array[i]+b_array[i-1])+")";
}
}
function qd_hs():Void {
a_array[i] = Number(abl);
b_array[i] = Number(bbl);
if (!jiaf.selected && !jianf.selected) {
xl_hs(0, 0, a_array[i], b_array[i]);
} else if (jiaf.selected) {
i--;
xl_hs(0, 0, (a_array[i-1]+a_array[i]), (b_array[i-1]+b_array[i]));
_root.lineStyle(1, 0xff0000, 80);
_root.moveTo(x0+a_array[i-1]*x_d, y0-b_array[i-1]*y_d);
_root.lineTo(x0+(a_array[i-1]+a_array[i])*x_d, y0-y_d*(b_array[i-1]+b_array[i]));
_root.moveTo(x0+x_d*a_array[i], y0-y_d*b_array[i]);
_root.lineTo(x0+x_d*(a_array[i-1]+a_array[i]), y0-y_d*(b_array[i-1]+b_array[i]));
} else if (jianf.selected) {
i--;
_root.lineStyle(1, 0x000000, 100);
_root.moveTo(x0+a_array[i]*x_d, y0-b_array[i]*y_d);
_root.lineTo(x0+a_array[i-1]*x_d, y0-b_array[i-1]*y_d);
_root.moveTo(x0, y0);
_root.lineTo(x0+x_d*(a_array[i-1]-a_array[i]), y0-y_d*(b_array[i-1]-b_array[i]));
_root.attachMovie("dot", "dot"+j, j);
_root["dot"+j]._x = x0+x_d*(a_array[i-1]-a_array[i]);
_root["dot"+j]._y = y0-y_d*(b_array[i-1]-b_array[i]);
_root["dot"+j]._rotation = jd(x0, y0, x0+x_d*(a_array[i-1]-a_array[i]), y0-y_d*(b_array[i-1]-b_array[i]));
_root.createTextField("t"+j, 10+j, x0+x_d*(a_array[i-1]-a_array[i]), y0-y_d*(b_array[i-1]-b_array[i]), 60, 30);
_root["t"+j].text = "("+(a_array[i-1]-a_array[i])+","+(b_array[i-1]-b_array[i])+")";
}
abl = "";
bbl = "";
i++;
j++;
}
//
qd_btn.onPress = function() {
qd_hs();
};
cz_btn.onPress = function() {
for (n=0; n
本文转自:http://www.5uflash.com/flashjiaocheng/Flashaschengxu/276.html
var y0:Number = zb_mc._y;
var x_d:Number = zb_mc._width/16;
var y_d:Number = zb_mc._height/16;
var a_array:Array = new Array();
var b_array:Array = new Array();
var i:Number = 0;
var j:Number = 0;
//计算向量角度的函数:
function jd(x1:Number, y1:Number, x2:Number, y2:Number) {
var d:Number = Math.sqrt(Math.pow(x2-x1, 2)+Math.pow(y2-y1, 2));
var jiaodu:Number = Math.abs(Math.acos((x2-x1)/d)*180/(Math.PI));
if (y1>y2 && x1y2 && x2x2) {
return 90+jiaodu;
} else if (y1y2 && x1 == x2) {
return 90-jiaodu;
} else if (y1x2) {
return 90-jiaodu;
}
}
//
function xl_hs(x1:Number, y1:Number, x2:Number, y2:Number):Void {
_root.lineStyle(1, 0x0000ff, 100);
_root.moveTo(x0+x1*x_d, y0-y1*y_d);
_root.lineTo(x0+x2*x_d, y0-y2*y_d);
_root.attachMovie("dot", "dot"+j, j);
_root["dot"+j]._rotation = jd(x0, y0, x0+x2*x_d, y0-y2*y_d);
_root["dot"+j]._x = x0+x2*x_d;
_root["dot"+j]._y = y0-y2*y_d;
_root.createTextField("t"+j, 10+j, x0+x2*x_d, y0-y2*y_d, 60, 30);
if (!jiaf.selected && !jianf.selected) {
_root["t"+j].text = "("+a_array[i]+","+b_array[i]+")";
} else if (jiaf.selected) {
_root["t"+j].text = "("+(a_array[i]+a_array[i-1])+","+(b_array[i]+b_array[i-1])+")";
}
}
function qd_hs():Void {
a_array[i] = Number(abl);
b_array[i] = Number(bbl);
if (!jiaf.selected && !jianf.selected) {
xl_hs(0, 0, a_array[i], b_array[i]);
} else if (jiaf.selected) {
i--;
xl_hs(0, 0, (a_array[i-1]+a_array[i]), (b_array[i-1]+b_array[i]));
_root.lineStyle(1, 0xff0000, 80);
_root.moveTo(x0+a_array[i-1]*x_d, y0-b_array[i-1]*y_d);
_root.lineTo(x0+(a_array[i-1]+a_array[i])*x_d, y0-y_d*(b_array[i-1]+b_array[i]));
_root.moveTo(x0+x_d*a_array[i], y0-y_d*b_array[i]);
_root.lineTo(x0+x_d*(a_array[i-1]+a_array[i]), y0-y_d*(b_array[i-1]+b_array[i]));
} else if (jianf.selected) {
i--;
_root.lineStyle(1, 0x000000, 100);
_root.moveTo(x0+a_array[i]*x_d, y0-b_array[i]*y_d);
_root.lineTo(x0+a_array[i-1]*x_d, y0-b_array[i-1]*y_d);
_root.moveTo(x0, y0);
_root.lineTo(x0+x_d*(a_array[i-1]-a_array[i]), y0-y_d*(b_array[i-1]-b_array[i]));
_root.attachMovie("dot", "dot"+j, j);
_root["dot"+j]._x = x0+x_d*(a_array[i-1]-a_array[i]);
_root["dot"+j]._y = y0-y_d*(b_array[i-1]-b_array[i]);
_root["dot"+j]._rotation = jd(x0, y0, x0+x_d*(a_array[i-1]-a_array[i]), y0-y_d*(b_array[i-1]-b_array[i]));
_root.createTextField("t"+j, 10+j, x0+x_d*(a_array[i-1]-a_array[i]), y0-y_d*(b_array[i-1]-b_array[i]), 60, 30);
_root["t"+j].text = "("+(a_array[i-1]-a_array[i])+","+(b_array[i-1]-b_array[i])+")";
}
abl = "";
bbl = "";
i++;
j++;
}
//
qd_btn.onPress = function() {
qd_hs();
};
cz_btn.onPress = function() {
for (n=0; n
本文转自:http://www.5uflash.com/flashjiaocheng/Flashaschengxu/276.html