Mouse limit

Hi , i need limit the mouse of left to right with a mc .

onClipEvent (enterFrame) {
    if (_parent.mainVar == 0) {
        homeX = (-_parent._xmouse*3)+700;
    } else {
        homeX = (-_parent.mainVar*3)+700;
    }
    thisX = _x;
    diffX = homeX-thisX;
    
    if (_root.mainVar == 0) {
        moveX = diffX/35;
    } else {
        moveX = diffX/5;
    }
    _x = thisX+moveX;
}