import flash.events.Event; import flash.events.MouseEvent; import flash.display.Sprite;
//听说shape比sprite节省资源 var circle:Sprite=new Sprite(); circle.graphics.beginFill(0); //试着把circle.graphics.drawCircle(100,100,10)发现每次偏移,说明每次startDrag()方法会重绘 circle.graphics.drawCircle(0,0,10); circle.graphics.endFill(); stage.addChild(circle); circle.addEventListener(MouseEvent.MOUSE_DOWN,startdrag); circle.addEventListener(MouseEvent.MOUSE_UP,stopdrag);
function startdrag(e:MouseEvent):void{ circle.startDrag(true); } function stopdrag(e:MouseEvent):void{ circle.stopDrag(); }