Drag with easing

i have this script that i am using to drag with easing. it works but how do i make sure it stops when it gets to the edge of the movie. Right now since there is easing on it, you can throw the shape right off of the stage. Is there a way it can stop?

rL

this code on the MC:

onClipEvent (load) {
	xfinal = _x;
	yfinal = _y;
}
onClipEvent (enterFrame) {
	if (drag) {
		x = _root._xmouse+xd;
		y = _root._ymouse+yd;
	} else {
		x = xfinal+xd;
		y = yfinal+yd;
	}
	_x = _x+(x-_x)/1.3;
	_y = _y+(y-_y)/1.3;
}

this code on the button inside of MC:

on (press) {
	drag = true;
	xd = _x-_root._xmouse;
	yd = _y-_root._ymouse;
	Mouse.show();
}
on (release, releaseOutside) {
	drag = false;
	xfinal = _root._xmouse;
	yfinal = _root._ymouse;
	Mouse.show();
}