IMAGE: Idle Scroll

Hi,

I’m using the following code to continuously scroll an image. I want to keep the mouseover but I need a way to make it scroll at an idle speed when the mouse isn’t over the image. I’d greatly appreciate any help.

 onClipEvent (load)
 {
 mouseOn = false;
 xcenter=600;
 speed=1/10;
 }
 
 on(rollOver)
 {
 mouseOn = true;
 }
 
 on(rollOut)
 {
 mouseOn = false;
 }
 
 onClipEvent (enterFrame)
 {
 if(mouseOn)
 {
 var distance=_root._xmouse-xcenter;
 _x+=(distance*speed);
 if (_x > 0) _x=-1950;
 if (_x < -1950) _x=0;
 }
 }

I also noticed the image jumps to the left when the mouse is over it. Any ideas on that?

 Thanks

You can’t have on() events inside a MovieClip. Try this code:

onClipEvent (load) {
mouseOn = false;
xcenter=600;
speed=1/10;
}

onClipEvent (enterFrame) {
if(hitTest(_root._xmouse, _root._ymouse, true)) {
var distance=_root._xmouse-xcenter;
_x+=(distance*speed);
if (_x > 0) _x=-1950;
if (_x < -1950) _x=0;
} else {
//do your idle thang
}
}

do you know the code so it still idles when the mouse isn’t over the image?

well, when the mouse isn’t over the object, the motion stops. Where I put “//do your idle thang” you insert the code that you want to run when the mouse isn’t over the object. I’ll leave that to you.

ok… I am new to flash
Thank you for your help by the way.

I’m using a mask on the image. With your code the image scrolls as long as it’s on the image’s Y axis. The first code only scrolls when the mouse is on the masked part of the image (or would the part of the image you can see be the unmasked?) Have any idea how I can get that with your code?

I think I figured it out. Does this look right to you?:

onClipEvent (load) {
mouseOn = false;
xcenter=600;
speed=1/10;
}

onClipEvent (enterFrame) {
if(hitTest(_root._xmouse, _root._ymouse, true)) {
var distance=_root._xmouse-xcenter;
_x+=(distance*speed);
if (_x > 0) _x=-1950;
if (_x < -1950) _x=0;
} else {
//onClipEvent (enterFrame) {
_x -= 5;
if (_x<-1950) {
_x = 0;
}
}
}