hi folks, trying to code a horizontal scrolling bar based on Photoscroller 2.0 (by Barry Driessen) but can’t get it to scroll smoothly: it should respond to mouse position (if near the left end, scrolls to the right and so on), but its movement is too fast - you can’t even see the scrolling, it goes from the original place to the destination without any intermediate position. need some help here! have a look at the code:
// declare some vars
var widthMovie:Number = 710;
var scrollSpeed:Number = 15; // <- can't understand this var...
var speed:Number;
var xPhoto:Number = 0;
var xMouse:Number;
// event listeners
myBar.addEventListener(MouseEvent.ROLL_OVER, myBarOVER);
function myBarOVER(myEvent:MouseEvent){
myBar.addEventListener(MouseEvent.MOUSE_MOVE, myBarMOVE);
}
function myBarMOVE(myEvent:MouseEvent){
// xMouse is zero in the center of the viewed area of the bar
xMouse = mouseX - (widthMovie / 2);
speed = (xMouse) / scrollSpeed; // <-- what does this bit do, really?
// all negative speeds to positive
if (speed < 0) {
speed = -(speed);
}
//left side
if (xMouse < -300) {
// got the impression the line below is currently useless in this script
// but also got the impression it is probably the most important...
// HELP NEEDED HERE
// how to set xPhoto to update smoothly myBar's x position according to mouse pos?
xPhoto = xMouse + speed;
//the if below locks the scrolling to prevent it from going too far
if (xPhoto < 0) {
xPhoto = 0;
}
}
// right side
if (xMouse > 300) {
xPhoto = -xMouse + speed;
if (xPhoto < -87) {
xPhoto = -87;
}
}
myBar.x=xPhoto;
}
all the help is appreciated!
many thanks,
ddd_estudio