# Scrolling images on rollover

**URL:** <https://forum.kirupa.com/t/scrolling-images-on-rollover/260218>\
**Category:** flash\
**Created:** [May 13, 2008, 3:43pm UTC](https://forum.kirupa.com/t/scrolling-images-on-rollover/260218 "2008-05-13T15:43:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomSaunders](https://avatars.discourse-cdn.com/v4/letter/t/65b543/32.png) [@TomSaunders](https://forum.kirupa.com/u/TomSaunders)\
**Post date:** [May 13, 2008, 3:43pm UTC](https://forum.kirupa.com/t/scrolling-images-on-rollover/260218/1 "2008-05-13T15:43:04Z")

</div>

Hi Everybody,

I have a scrolling image panel which works fine, but I’d like it to only scroll on rollover.

The script I have has onEnterFrame but it still rolls over wherever your mouse is.

Please could somebody help me modify my script so that it only works on rollover?

Many thanks,

Tom

Here’s the script:

onClipEvent (enterFrame) {  
//movie clip enterframe event  
\_x = \_x+2;  
//change position for each enterframe event  
if (\_x\>=2588) {  
//condition  
\_x = -2588;  
//if condition true movie clip jumps to starting postion.  
}  
}

---

<div class="post-metadata">

**Author:** ![findAll](https://avatars.discourse-cdn.com/v4/letter/f/4da419/32.png) [@findAll](https://forum.kirupa.com/u/findAll)\
**Post date:** [May 13, 2008, 8:15pm UTC](https://forum.kirupa.com/t/scrolling-images-on-rollover/260218/2 "2008-05-13T20:15:07Z")

</div>

So, let’s suppose your panel instance name is myPanel, go in the main timeline and put this code:

```auto

myPanel.onRollOver = function(){
this.onEnterFrame = function(){
this._x += 2;
if(this._x>=2588){
this._x = -2588
}
}
}

```

It should work. But if your panel is a movieclip with other movieclip inside on which you rollOver, you might encounter other unpleasant situation: rolling over nested movieclips. If so, I could point you to a very useful tutorial that will help you solve it 🙂

cheers…
