# Scrolling with mouse

**URL:** <https://forum.kirupa.com/t/scrolling-with-mouse/193688>\
**Category:** Uncategorized\
**Created:** [July 15, 2006, 7:57am UTC](https://forum.kirupa.com/t/scrolling-with-mouse/193688 "2006-07-15T07:57:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tim28435](https://avatars.discourse-cdn.com/v4/letter/t/bbce88/32.png) [@tim28435](https://forum.kirupa.com/u/tim28435)\
**Post date:** [July 15, 2006, 7:57am UTC](https://forum.kirupa.com/t/scrolling-with-mouse/193688/1 "2006-07-15T07:57:40Z")

</div>

hi, i have this code:

onClipEvent (enterFrame) {  
if (this.\_x\<=40 and this.\_x\>=-800) {  
\_root.yChange = Math.round(\_root.\_ymouse-this.\_y);  
// Calculates the distance between the movie clip and the mouse  
\_root.xChange = Math.round(\_root.\_xmouse-365);  
// Calculates the distance between the movie clip and the mouse  
\_root.yMove = Math.round(\_root.yChange/20);  
// Determines the amount the movie clip should move toward the mouse, grows larger the further the mouse gets from the MC  
\_root.xMove = Math.round(\_root.xChange/20);  
// See above  
this.\_x -= \_root.xMove;  
}  
if (this.\_x\>=40) {  
this.\_x = 30;  
}  
if (this.\_x\<=-800) {  
this.\_x = -780;  
}  
}

at the moment, the movie clip moves so it reveals more in that direction and when it gets to a certain point it stops and moves the movieclip back inside the boundaries.  
the problem is that as it comes to the ends/boundaries it flickers (once it is placed back inside the boundary it starts scrolling again and then keeps jumping back again)

how can i stop this?  
is there a better way to script this?

thanks
