Draggable movieclip - problem

I’ve had a good hunt round but can’t find how I do this.

_root.box.ease = 2;
_root.box.targX = _root.myMC._x;
_root.box.targY = _root.myMC._y
_root.box.onPress = function() {
    this.drag = true;
};
_root.box.onEnterFrame = function() {
    if (this.drag == true) {
        this.targX = _root._xmouse;
        this.targY = _root._ymouse;
    }
    if (this._x != this.targX | this._y != this.targY) {
        this._x += (this.targX-this._x)/this.ease;
        this._y += (this.targY-this._y)/this.ease;
    }
};
_root.box.onMouseUp = function() {
    this.drag = false;
};

I’m using that code to drag my movie clip ‘box’ around with some easing to make it look a bit more fluid.

I used some code from here actually after alot of hunting around.

Now I want to ensure it doesn’t fly off the stage. How do I go about constraining it to the stage?

I’ve seen you can do something like…

[COLOR=#0066CC]on[/COLOR] [COLOR=#66CC66]([/COLOR]press[COLOR=#66CC66])[/COLOR] [COLOR=#66CC66]{[/COLOR]
        [COLOR=#0066CC]startDrag[/COLOR] [COLOR=#66CC66]([/COLOR][COLOR=#0066CC]this[/COLOR], [COLOR=#000000]**true**[/COLOR], [COLOR=#CC66CC]30[/COLOR], [COLOR=#CC66CC]80[/COLOR], [COLOR=#CC66CC]140[/COLOR], [COLOR=#CC66CC]110[/COLOR][COLOR=#66CC66])[/COLOR];
[COLOR=#66CC66]}[/COLOR]

But I can’t for the life of me figure out how to put that theory into the code above.

I’m not really an actionscript guru…well not an actionscript guru hehe more a cobbler together and mess around some so I’m scratching my head alot here.

Any help be grateful.

Cheers