# Perspective scrolling/follow mouse

**URL:** <https://forum.kirupa.com/t/perspective-scrolling-follow-mouse/202202>\
**Category:** flash\
**Created:** [September 28, 2006, 6:30pm UTC](https://forum.kirupa.com/t/perspective-scrolling-follow-mouse/202202 "2006-09-28T18:30:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![FlashFish](https://avatars.discourse-cdn.com/v4/letter/f/b9e5f3/32.png) [@FlashFish](https://forum.kirupa.com/u/FlashFish)\
**Post date:** [September 28, 2006, 6:30pm UTC](https://forum.kirupa.com/t/perspective-scrolling-follow-mouse/202202/1 "2006-09-28T18:30:49Z")

</div>

Hi. I am trying to create that perspective effect where movie clips move along the x axis at different speeds so it looks kind of 3dish. I’ve adapted the follow mouse code from the tutorial here on kirupa and got this far:

onClipEvent (load) {  
\_x = stage.width/2;  
speed = 100;  
}  
onClipEvent (enterFrame) {  
endX = \_root.\_xmouse;

```
_x += (endX-_x)/speed;

```

}  
I have this code on 3 different mcs at 3 different speeds which looks ok. Problem is at the moment they follow the mouse and I would like them to be repelled by the mouse; exactly the same, but the opposite. I had a fiddle and tried the speeds as minus numbers but it went a bit odd, it looked as if it was gonna work but things just flew off the screen. Any help would be great, thanks in advance.

\<"))))\>\<
