# Constraining Relative Mouse Position Action to Area

**URL:** <https://forum.kirupa.com/t/constraining-relative-mouse-position-action-to-area/215784>\
**Category:** flash\
**Created:** [February 10, 2007, 7:13am UTC](https://forum.kirupa.com/t/constraining-relative-mouse-position-action-to-area/215784 "2007-02-10T07:13:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flashapotomus](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/flashapotomus/32/3294_2.png) [@flashapotomus](https://forum.kirupa.com/u/flashapotomus)\
**Post date:** [February 10, 2007, 7:13am UTC](https://forum.kirupa.com/t/constraining-relative-mouse-position-action-to-area/215784/1 "2007-02-10T07:13:25Z")

</div>

I’ve scoured several places online for an answer to this, but I only find posts asking the same question without any answers. I would appreciate any guidance on this.

I’ve successfully implemented a looping MC slider (w/ buttons) that eases horizontally according to mouse position. The problem is, I can’t get the slider to stop moving when the mouse is outside of the slider MC area. My slider MC is loaded into a layer above my main movie, and I would like to retain the functionality of the links on the main timeline without the distraction of the moving horizontal slider. In any event, I can’t even find a way to constrain the relative mouse action at all.

Here is the basic AS I am using:

```auto
panel.onRollOver = panelOver;

function panelOver() {
    this.onEnterFrame = scrollPanel;
    delete this.onRollOver;
}

var b = stroke.getBounds(_root);

function scrollPanel() {
    if(_xmouse<b.xMin || _xmouse>b.xMax || _ymouse<b.yMin || _ymouse>b.yMax) {
        this.onRollOver = panelOver;
        delete this.onEnterFrame;
    }
    
    if(panel._x >= -121) {
        panel._x = -1825;
    }
    
    if(panel._x <= -1847) {
        panel._x = -140;
    }
    
    var xdist = _xmouse - 250;
    
    panel._x += Math.round(-xdist / 10);
}

```
