Drag – Limiting mc to be dragged horizontally or vertically

Hey guys, I the following problem which I hope you can answer, since the many hours I’ve spent googling it hasn’t helped out :frowning:

I got a movieclip which should be dragable horizontally and vertically, however it should be “locked” horizontally when dragging vertically as well as the other way around.

Here’s the following code I’m using to drag it horizontally:

[LEFT][COLOR=#993300]var[/COLOR] leftX:[COLOR=#993300]int[/COLOR] = [COLOR=#000000]0[/COLOR]; 
[COLOR=#993300]var[/COLOR] rightX:[COLOR=#993300]int[/COLOR] = [COLOR=#993300]stage[/COLOR].[COLOR=#000000]stageWidth[/COLOR]; 

my_mc.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]MOUSE_DOWN[/COLOR], onDown[COLOR=#000000])[/COLOR]; 
my_mc.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]MOUSE_UP[/COLOR], onUp[COLOR=#000000])[/COLOR];  
[COLOR=#993300]
function[/COLOR] onDown[COLOR=#000000]([/COLOR][COLOR=#993300]e[/COLOR]:MouseEvent[COLOR=#000000])[/COLOR]:[COLOR=#993300]void[/COLOR] [COLOR=#000000]{[/COLOR]     [COLOR=#993300]

var[/COLOR] constrainY:Rectangle = [COLOR=#993300]new[/COLOR] Rectangle[COLOR=#000000]([/COLOR]leftX, [COLOR=#993300]e[/COLOR].[COLOR=#000000]currentTarget[/COLOR].[COLOR=#000000]y[/COLOR], rightX, [COLOR=#000000]0[/COLOR][COLOR=#000000])[/COLOR];     [COLOR=#993300]

e[/COLOR].[COLOR=#000000]currentTarget[/COLOR].[COLOR=#993300]startDrag[/COLOR][COLOR=#000000]([/COLOR][COLOR=#993300]false[/COLOR], constrainY[COLOR=#000000])[/COLOR]; [COLOR=#000000]}[/COLOR]  [COLOR=#993300]

function[/COLOR] onUp[COLOR=#000000]([/COLOR][COLOR=#993300]e[/COLOR]:MouseEvent[COLOR=#000000])[/COLOR]:[COLOR=#993300]void[/COLOR] [COLOR=#000000]{[/COLOR]     [COLOR=#993300]

e[/COLOR].[COLOR=#000000]currentTarget[/COLOR].[COLOR=#993300]stopDrag[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR]; [COLOR=#000000]
}
[/COLOR]
[/LEFT]

[COLOR=#000000]If I haven’t explained myself clear enough, I’m trying to create the effect that can be seen on [/COLOR]http://www.griplimited.com/