// define lock on y-axis
var LOCKY:Number = target.y;
// MouseEvent.MOUSE_MOVE
stage.addEventListener(MouseEvent.MOUSE_MOVE, _mouseMove);
function _mouseMove(e:MouseEvent):void
{
if(target.y != LOCKY) target.y = LOCKY;
}
// dragging
target.addEventListener(MouseEvent.MOUSE_DOWN, _mouseDown);
function _mouseDown(e:MouseEvent):void
{
target.startDrag();
target.addEventListener(MouseEvent.MOUSE_UP, _mouseUp);
}
// dropping
function _mouseUp(e:MouseEvent):void
{
target.stopDrag();
target.removeEventListener(MouseEvent.MOUSE_UP, _mouseUp);
}
Taken directly from here:
AS3 How to startdrag only on x-axis?