// 主程序
// 要点1:鼠标位置属性(_xmouse,_ymouse)
// 要点2:Math Objects
// 日期:2000-09-02
// 作者:kanaka
// Email:kanaka@yeah.net
onClipEvent (mouseUp) {
if (_root.FirstPointDrew == 0) {
// 读取起点的坐标
x1 = _xmouse;
y1 = _ymouse;
// 如果已经画过一条线,则将线和两个点都删除,以保持场景清洁
if (_root.LineDrew == 1) {
removeMovieClip (point1);
removeMovieClip (point2);
removeMovieClip (line1);
}
// 在起点坐标上画一个点
duplicateMovieClip (point, "point1", 1);
setProperty (point1, _x, x1);
setProperty (point1, _y, y1);
// 起点已经画出
_root.FirstPointDrew = 1;
} else {
// 读取终点的坐标
x2 = _xmouse;
y2 = _ymouse;
// 在终点坐标上画一个点
duplicateMovieClip (point, "point2", 2);
setProperty (point2, _x, x2);
setProperty (point2, _y, y2);
// 终点已经画出,置 FirstPointDrew 为 0
_root.FirstPointDrew = 0;
// 计算三角形三条边的长度
x = Math.abs(x1-x2);
y = Math.abs(y1-y2);
z = Math.sqrt(x*x+y*y);
// 计算画线的旋转角度
if ((x1$#@60;x2) and (y1$#@62;y2)) {
angel = Math.atan(y/x)/Math.PI*180;
} else if ((x1=x2) and (y1$#@60;y2)){
angel = Math.atan(x/y)/Math.PI*180+90;
} else if ((x1x2) and (y1$#@62;=y2)){
angel = Math.atan(y/x)/Math.PI*180+180;
} else {
angel = 360-Math.atan(y/x)/Math.PI*180;
}
// 设置画线动画的起始坐标 醴疟壤托嵌?br duplicateMovieClip (line, "line1", 0);
setProperty (line1, _x, x1);
setProperty (line1, _y, y1);
setProperty (line1, _xscale, z/_root.LineWide*100);
setProperty (line1, _rotation, angel);
// 画线完成
_root.LineDrew = 1;
}
}
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/fjc/)
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/fjc/)