# Advanced Sliding | mc related to mouse position

**URL:** https://forum.kirupa.com/t/advanced-sliding-mc-related-to-mouse-position/242400
**Category:** flash
**Created:** [October 25, 2007, 3:31pm UTC](https://forum.kirupa.com/t/advanced-sliding-mc-related-to-mouse-position/242400 "2007-10-25T15:31:04Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![penlix](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/penlix/32/3365_2.png) [@penlix](https://forum.kirupa.com/u/penlix)
#### Post date: [October 25, 2007, 3:31pm UTC](https://forum.kirupa.com/t/advanced-sliding-mc-related-to-mouse-position/242400/1 "2007-10-25T15:31:04Z")

</div>

Hi,

I have been building a movie and I am using the following script to  
move my mc left or right. However, this looks pretty simple and  
I was really looking to reach the level of [Vodafone this movie’s animation](http://online.vodafone.co.uk/dispatch/Portal/appmanager/vodafone/wrp?_nfpb=true&_pageLabel=template12&pageID=MI_0002&redirectedByRedirectsImplServletFlag=true),  
where the mc stops sliding, when the mouse is not moving

This is the code I am using so far and it works fine, but with no easing,  
and it moves continuously…:

```auto
xcenter = 250;
speed = 1/70;
videos.onEnterFrame = function() {
    var distance = _root._xmouse-xcenter;
    videos._x -= (distance*speed);
    if (videos._x<= -100) {
        videos._x = -100;
    }
    if (videos._x>=0) {
        videos._x = 0;
    }
};

```

Thanks in advance for your help,

Kostas
