# Mouse detected scrolling interface

**URL:** <https://forum.kirupa.com/t/mouse-detected-scrolling-interface/119017>\
**Category:** Uncategorized\
**Created:** [August 10, 2004, 11:17pm UTC](https://forum.kirupa.com/t/mouse-detected-scrolling-interface/119017 "2004-08-10T23:17:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gomango](https://avatars.discourse-cdn.com/v4/letter/g/bb73d2/32.png) [@gomango](https://forum.kirupa.com/u/gomango)\
**Post date:** [August 10, 2004, 11:17pm UTC](https://forum.kirupa.com/t/mouse-detected-scrolling-interface/119017/1 "2004-08-10T23:17:13Z")

</div>

[font=verdana, arial, helvetica][size=2]Using this script to provide a auto scrolling interface. Need an area in the center that does not scroll. Also wanted to add the \_ymouse scroll too.

onClipEvent (enterFrame) {  
shift = ((400-\_root.\_xmouse)/20);  
if (((this.\_x\>=1300) && (shift\>0)) || ((this.\_x\<=-500) && (shift\<0))) {  
shift = 0;  
}  
this.\_x = this.\_x+shift;  
[/size][/font]

---

<div class="post-metadata">

**Author:** ![Prophet](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@Prophet](https://forum.kirupa.com/u/Prophet)\
**Post date:** [August 10, 2004, 11:54pm UTC](https://forum.kirupa.com/t/mouse-detected-scrolling-interface/119017/2 "2004-08-10T23:54:33Z")

</div>

ok because of the way it is calculated… there is one way to do it without changing its calculation… at least one way i can see how you could do it anyway…

```auto
shift = ((400-_root._xmouse)/20)
if(shift >=-2 && shift <=2){
	shift = 0
}
if(shift>2){
	shift -=2
}
if(shift<-2){
	shift +=2
}

```

replace the line

```auto
shift = ((400-_root._xmouse)/20)

```

with what i have above and you should be home free as they say 😉

note that my code will give you an x area of 4 that equates to 0… play with the numbers as you like… for the y simply use this:

```auto
Yshift = ((400-_root._ymouse)/20)
if(Yshift >=-2 && Yshift <=2){
	Yshift = 0
}
if(Yshift>2){
	Yshift -=2
}
if(Yshift<-2){
	Yshift +=2
}
if (((this._y>=1300) && (Yshift>0)) || ((this._y<=-500) && (Yshift<0))) {
	Yshift = 0;
}
this._y = this._y+Yshift

```

again play with the numbers as is fitting to you…

i also strongly reccomend changing the name of the variable _shift_ (used in the x calculations) to something else like _Xshift_ not only is it more descriptive and easier to identify but also _shift_ is a flash keyword (used in arrays) and as such it might get a bit confusing if you get irrelevant code hints as flash is thinking you are trying to play around with an array and so on and so forth…

enjoy anyway 😉

Prophet.

---

<div class="post-metadata">

**Author:** ![gomango](https://avatars.discourse-cdn.com/v4/letter/g/bb73d2/32.png) [@gomango](https://forum.kirupa.com/u/gomango)\
**Post date:** [August 11, 2004, 2:20am UTC](https://forum.kirupa.com/t/mouse-detected-scrolling-interface/119017/3 "2004-08-11T02:20:00Z")

</div>

Thanks for your quick response. I could not get this to work. I have no skill in programming. Can you write the whole script with the onClipEvent so I can paste the complete code and not screw it up, you know, idiot proof. I also need some script to keep both shift actions from happening at the same time.

What I am tryig to do is scroll my page content by making movie clip, I need the majority of the page to not scroll so visitors can select items without the page moving. Run there mouse to the edge and it scrolls. But what about smaller screen resolutions. The working area should be what size? I also want the top 150 px on the page for my header, so no scrolling when the mouse is there either. I could send you my file. If you know any other way to get the same results, lets do it.

Can I please pay you?

> [@Prophet](#):
>
> ok because of the way it is calculated… there is one way to do it without changing its calculation… at least one way i can see how you could do it anyway…
> 
> ```auto
> shift = ((400-_root._xmouse)/20)
> if(shift >=-2 && shift <=2){
> shift = 0
> }
> if(shift>2){
> shift -=2
> }
> if(shift<-2){
> shift +=2
> }
> 
> ```
> 
> replace the line
> 
> ```auto
> shift = ((400-_root._xmouse)/20)
> 
> ```
> 
> with what i have above and you should be home free as they say 😉
> 
> note that my code will give you an x area of 4 that equates to 0… play with the numbers as you like… for the y simply use this:
> 
> ```auto
> Yshift = ((400-_root._ymouse)/20)
> if(Yshift >=-2 && Yshift <=2){
> Yshift = 0
> }
> if(Yshift>2){
> Yshift -=2
> }
> if(Yshift<-2){
> Yshift +=2
> }
> if (((this._y>=1300) && (Yshift>0)) || ((this._y<=-500) && (Yshift<0))) {
> Yshift = 0;
> }
> this._y = this._y+Yshift
> 
> ```
> 
> again play with the numbers as is fitting to you…
> 
> i also strongly reccomend changing the name of the variable _shift_ (used in the x calculations) to something else like _Xshift_ not only is it more descriptive and easier to identify but also _shift_ is a flash keyword (used in arrays) and as such it might get a bit confusing if you get irrelevant code hints as flash is thinking you are trying to play around with an array and so on and so forth…
> 
> enjoy anyway 😉
> 
> Prophet.

---

<div class="post-metadata">

**Author:** ![Prophet](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@Prophet](https://forum.kirupa.com/u/Prophet)\
**Post date:** [August 11, 2004, 5:07pm UTC](https://forum.kirupa.com/t/mouse-detected-scrolling-interface/119017/4 "2004-08-11T17:07:59Z")

</div>

[samyoue@gmail.com](mailto:samyoue@gmail.com)

give me absolute full descriptions of what you want (and illustrations if poss - sometimes i can be a little thick when it comes to design etc lol)

happy to help u 🙂

Prophet.
