/**
* liveTea
*/
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.filters.DropShadowFilter;
import flash.geom.Point;
import flash.display.DisplayObject;
public class DrawDragTest extends Sprite
{
private var _drawing:Boolean;
private var _circle:Sprite;
private var beginLocation

public function DrawDragTest()
{
graphics.lineStyle(1,0,1);
_drawing=false;
stage.addEventListener(MouseEvent.MOUSE_DOWN,drawBegin);
stage.addEventListener(MouseEvent.MOUSE_MOVE,drawing);
stage.addEventListener(MouseEvent.MOUSE_UP,drawEnd);
//
_circle=new Sprite();
_circle.graphics.beginFill(939878393,1)
_circle.graphics.drawCircle(20,20,30);
_circle.graphics.endFill();
addChild(_circle);
_circle.addEventListener(MouseEvent.MOUSE_DOWN,dragBegin);
_circle.addEventListener(MouseEvent.MOUSE_UP,dragEnd);
}
private function dragBegin(event:MouseEvent):void{
beginLocation=new Point();
beginLocation.x=event.target.x;
beginLocation.y=event.target.y;
//event.target.
//event.target.
event.target.startDrag();
event.target.filters=[new DropShadowFilter()];
}
private function dragEnd(event:MouseEvent):void{
event.target.stopDrag();
event.target.filters=null;
event.target.x=beginLocation.x;
event.target.y=beginLocation.y;
}
private function drawBegin(event:MouseEvent):void{
graphics.moveTo(mouseX,mouseY);
_drawing=true;
}
private function drawing(event:MouseEvent):void{
if(_drawing)
{
graphics.lineTo(mouseX,mouseY);
}
}
private function drawEnd(event:MouseEvent):void{
_drawing=false;
}
}
}