Restrict _xmouse and _ymouse to box

Hi. I am making a menu with 5 pictures in one movie clip and I have a mc of a line ( all on frame 1) and it’s code is:
onClipEvent (enterFrame) {
with (_root.menu) {
diff = (this._x-_root._xmouse)/10;
_root.menu._x = _root.menu._x +diff;
}
}

but I want to make another movie clip in the shape of a rectangle and I want the menu only to slide if the mouse position changes in the rectangle. so I don’t want the picture mc to move if the mouse isn’t changing positions in the rectangle; it should just stay put. please help me boyies. thanks _root.brian

well… if the rectangle is a movieclip with an instance name you could do something like this.


onClipEvent (enterFrame) {
    if(_root._xmouse>_root.square._x&&_root._xmouse<_root.square._x+_root.square._width&&_root._ymouse>_root.square._y&&_root._ymouse<_root.square._y+_root.square._height){
        with (_root.menu) {
            diff = (this._x-_root._xmouse)/10;
            _root.menu._x = _root.menu._x +diff;
        }
    }
}

provided the square movie clip had an instance name of square and it was located on the main timeline.

as an alternative to David’s, check out the scriptable masks tutorial

http://www.kirupa.com/developer/actionscript/scriptable_masks.asp

in there, check out the explanation on getBounds. Go to the part that says “Almost Done”

thanks David. I can only get the menu to go to the left though.
either way I move the mouse it goes to the left and the speed is not consistent to the speed the mouse moves. please help a boy once more. thanks a bunch - brazil