Constrain a dragged movie clip to the stage
I have a movie clip (pano_mc) that I can click and drag left and right. When I drag it to the right, it stops dragging when the left edge of the clip reaches the left edge of the stage. This is great!
When I drag the image to the left, the right side edge if the clip does not stop at the right edge of the stage, but continues to click and drag until it reaches the left edge of the stage.
I need the left edge of the clip to stop at the left edge of the stage and the right edge of the clip to stop at the right edge of the stage.
Here is the code I have so far
The pano_mc is registered to the top right corner and is 7024px in length. I know it is a bit large.
The axis_mc is anchored to the upper left.
pano_mc.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
function fl_ClickToDrag(event:MouseEvent):void
{
if (pano_mc.x == 0) { //I have tried 7024, 3512 and 0 but none have been successful
pano_mc.stopDrag();
} else { pano_mc.startDrag(false,new Rectangle(axis_mc.x,axis_mc.y,7024,0)); }}stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
function fl_ReleaseToDrop(event:MouseEvent):void
{
pano_mc.stopDrag();
}
Any suggestions?