Hi,
I am doing a website where the background is moved with the mouse horizontally. I want it with a edge size ti avoid too much movement when the mouse is in the middle of the stage.
I followed a AS3 tutorial but I am working with AS2, then this with my not very good SA knoleadge is getting me mad. THis is the code
var mousePositionX:Number = 0;
var speedX:Number = 0;
var edge:Number = 100;
var scrollDivide:Number = 10;
stage.addEventListener(Event.ENTER_FRAME, calculate);
function calculate(Event) {
mousePositionX = _xmouse;
// Left edge.
if (mousePositionX >= 0 && mousePositionX < edge) {
speedX = (edge - mousePositionX) / scrollDivide;
scroller._x = Math.min(scroller._x + speedX, 0);
}
// Right edge.
else if (mousePositionX >= (Stage.width- edge) && mousePositionX < Stage.width) {
speedX = (mousePositionX - (Stage.width - edge)) / scrollDivide;
scroller._x = Math.max(scroller._x - speedX, Stage.width - scroller._width);
}
// The middle.
else {
}
}
Somebody could help me with that?
Thanks