import flash.geom.Point; function DrawCircle (target:MovieClip, fromPoint:Point, endPoint:Point, circleType:String):Void { /********************* * target:目标影片剪辑 * fromPoint: 开始点(虚拟圆的圆心) * endPoint: 鼠标的当前位置(由fromPoint到endPoint构成一个虚拟圆) * r: 半径(虚拟圆的半径) * z: 鼠标当前位置相对虚拟圆的角度 * circleType: 圆的类型,圆、椭圆、圆弧 ********************/ var r:Number = new Number (0); r = Math.sqrt (Math.pow ((endPoint.x - fromPoint.x), 2) + Math.pow ((endPoint.x - fromPoint.y), 2)); var z:Number = new Number (0); z = Math.atan2 ((endPoint.y - fromPoint.y), (endPoint.x - fromPoint.x)) * 180 / Math.PI; tempValue = Math.round (z); // target.clear (); target.lineStyle (_global.lineWidth, _global.lineColor, 100); //target.beginFill (_global.fillColor, 100); dx = (endPoint.x - fromPoint.x) / 2; dy = (endPoint.y - fromPoint.y) / 2; if (circleType == "实心圆") { target.beginFill (_global.fillColor, 100); dy = dx; } if (circleType == "空心圆") { dy = dx; } target.moveTo (fromPoint.x + dx * 2, fromPoint.y + dy); for (i = 0; i < (Math.PI * 2 + 0.1); i += 0.1) { newx = fromPoint.x + dx + dx * Math.cos (i); newy = fromPoint.y + dy - dy * Math.sin (i); target.lineTo (newx, newy); } }