package { import flash.display.Sprite; import flash.events.MouseEvent; public class as2 extends Sprite { private var _controlPoint:Sprite; private var _anchor0:Sprite; private var _anchor1:Sprite; public function as2() { _anchor0 = addControlPoint(50,300); _anchor1 = addControlPoint(500,300); _controlPoint = addControlPoint(275,100); drawCurve(); } private function addControlPoint(x:Number,y:Number):Sprite { var controlPoint:Sprite = new Sprite(); controlPoint.graphics.lineStyle(20); controlPoint.graphics.lineTo(1,0); controlPoint.addEventListener(MouseEvent.MOUSE_DOWN, onControlDown); controlPoint.addEventListener(MouseEvent.MOUSE_UP, onControlUp); controlPoint.x = x; controlPoint.y = y; addChild(controlPoint); return controlPoint; } private function drawCurve():void { graphics.clear(); graphics.lineStyle(3, 0xFF); graphics.moveTo(_anchor0.x,_anchor0.y); graphics.curveTo(_controlPoint.x,_controlPoint.y,_anchor1.x,_anchor1.y); graphics.lineStyle(1,0,.5); graphics.lineTo(_controlPoint.x,_controlPoint.y); graphics.lineTo(_anchor0.x,_anchor0.y); } private function onControlDown(event:MouseEvent):void { (event.target as Sprite).startDrag(); stage.addEventListener(MouseEvent.MOUSE_MOVE, onControlMove); } private function onControlUp(event:MouseEvent):void { (event.target as Sprite).stopDrag(); stage.removeEventListener(MouseEvent.MOUSE_MOVE,onControlMove); } private function onControlMove(event:MouseEvent):void { drawCurve(); event.updateAfterEvent(); } } }