试试下面的代码,我希望这是你需要的。
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.events.Event;
var pupil:MovieClip=new MovieClip();
var holder:MovieClip=new MovieClip();
var newPoint:Point = new Point();
var dist:Number;
pupil.graphics.lineStyle(1, 0x0000FF);
pupil.x = pupil.y = 100;
pupil.graphics.beginFill(0x0000FF, .1);
pupil.graphics.drawCircle(0, 0, 50);
//pupil.graphics.endFill();
holder.graphics.beginFill(0xFF0000);
holder.graphics.drawCircle(0,0, 5);
holder.graphics.endFill();
holder.x = pupil.width/2;
addChild(pupil);
pupil.addChild(holder);
holder.buttonMode = true;
holder.addEventListener(MouseEvent.MOUSE_DOWN, onHolderClikded);
holder.addEventListener(MouseEvent.MOUSE_UP, onHolderReleased);
function onHolderClikded(eve:MouseEvent):void{
holder.startDrag();
addEventListener(Event.ENTER_FRAME, onPointMoving)
}
function onPointMoving(eve:Event):void{
newPoint.x = holder.x;
newPoint.y = holder.y;
dist = Point.distance(new Point(0,0),newPoint.clone());
pupil.graphics.clear();
pupil.graphics.lineStyle(1, 0x0000FF);
pupil.graphics.beginFill(0x0000FF, .1);
pupil.graphics.drawCircle(0, 0, dist);
}
function onHolderReleased(eve:MouseEvent):void{
holder.stopDrag();
}