move movieClip within a range
I have 2 lines that are representing a range that the clip can move within a boundary if you like. My lines are named "left" and "right". What I'm trying to do is move the movieclip based on the mouseX but the mouseX should only move it within the range or boundaries.
Here is what I have so far.
Code:
var cp : Number = left.x + (right.x - left.x) / 2;
addEventListener(Event.ENTER_FRAME, onLoop);
var sx : Number = sq.x;
function onLoop( evt : Event ) : void
{
var dx : Number = cp - mouseX;
var range = right.x - left.x ;
sq.x = dx
//trace("dx = "+(dx ));
}
I have tried a few different ideas inside the above code but its driving me nuts when it seems like something very easy. The MovieClip should move based on the mouseX but should only move within the left and right clips as boundaries.