Можно как-то так:

Код AS3:
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
/**
* ...
* @author samana
*/
public class DragBlock extends Sprite
{
static public const HORIZONTAL:String = "horizontal";
static public const VERTICAL:String = "vertical";
private var orient:String;
public function DragBlock(w:Number,h:Number,orient:String)
{
this.orient = orient;
graphics.beginFill(0xCC00CC);
graphics.drawRect(0, 0, w, h);
graphics.endFill();
addEventListener(Event.ADDED_TO_STAGE, addedToStage);
addEventListener(Event.REMOVED_FROM_STAGE, removedFromStage);
}
private function removedFromStage(e:Event):void
{
removeEventListener(Event.REMOVED_FROM_STAGE, removedFromStage);
removeEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, stage_mouseMove);
stage.removeEventListener(MouseEvent.MOUSE_UP, stage_mouseUp);
}
private function addedToStage(e:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
}
private function mouseDown(e:MouseEvent):void
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, stage_mouseMove);
stage.addEventListener(MouseEvent.MOUSE_UP, stage_mouseUp);
}
private function stage_mouseUp(e:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, stage_mouseMove);
stage.removeEventListener(MouseEvent.MOUSE_UP, stage_mouseUp);
}
private function stage_mouseMove(e:MouseEvent):void
{
if (orient == HORIZONTAL) x = parent.mouseX;
if (orient == VERTICAL) y = parent.mouseY;
}
}
}