# Scroll Flash Website Using Mouse Movement

**URL:** <https://forum.kirupa.com/t/scroll-flash-website-using-mouse-movement/314717>\
**Category:** flash\
**Created:** [October 6, 2010, 9:58pm UTC](https://forum.kirupa.com/t/scroll-flash-website-using-mouse-movement/314717 "2010-10-06T21:58:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![t3553r](https://avatars.discourse-cdn.com/v4/letter/t/df788c/32.png) [@t3553r](https://forum.kirupa.com/u/t3553r)\
**Post date:** [October 6, 2010, 9:58pm UTC](https://forum.kirupa.com/t/scroll-flash-website-using-mouse-movement/314717/1 "2010-10-06T21:58:30Z")

</div>

I’m trying to create a website where you can scroll vertically simply by moving your mouse around the page. For example moving your mouse up would scroll up and moving your mouse down would scroll down…

I came across this tutorial [http://www.kirupa.com/developer/flash8/interactive\_image\_pan.htm](http://www.kirupa.com/developer/flash8/interactive_image_pan.htm) however it is used to scroll horizontally so I changed the Actionscript to the code below…

```auto
this.onMouseMove = function() {
    constrainedMove(bg_mc, 10, 1);
};
function constrainedMove(target:MovieClip, speed:Number, dir:Number) {
    var mousePercent:Number = _ymouse/Stage.height;
    var mSpeed:Number;
    if (dir == 1) {
        mSpeed = 1-mousePercent;
    } else {
        mSpeed = mousePercent;
    }
    target.destY = Math.round(-(target._height-Stage.height)*mSpeed);
    target.onEnterFrame = function() {
        if (target._y == target.destY) {
            delete target.onEnterFrame;
        } else if (target._y>target.destY) {
            target._y -= Math.ceil((target._y-target.destY)*(speed/100));
        } else if (target._y<target.destY) {
            target._y += Math.ceil((target.destY-target._y)*(speed/100));
        }
    };
}

```

So what I did was change all instance of width to height and changed all x’s to y’s.

Now the script works for scrolling vertically however when you move the mouse toward the top it scrolls down and when you move the mouse down it scrolls up. I want to get the script so it scrolls up when the mouse is moved up this way the user can click on the navigation at the top of the page without it scrolling down.

Any ideas?
