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 however it is used to scroll horizontally so I changed the Actionscript to the code below…
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?