# Creating movement with mouse cursor but with restrictions?

**URL:** <https://forum.kirupa.com/t/creating-movement-with-mouse-cursor-but-with-restrictions/291526>\
**Category:** Uncategorized\
**Created:** [July 1, 2009, 12:44am UTC](https://forum.kirupa.com/t/creating-movement-with-mouse-cursor-but-with-restrictions/291526 "2009-07-01T00:44:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eddie\_E](https://avatars.discourse-cdn.com/v4/letter/e/2acd7d/32.png) [@Eddie\_E](https://forum.kirupa.com/u/Eddie_E)\
**Post date:** [July 1, 2009, 12:44am UTC](https://forum.kirupa.com/t/creating-movement-with-mouse-cursor-but-with-restrictions/291526/1 "2009-07-01T00:44:48Z")

</div>

Hi

I have the following code which works fine but I would like to set a restriction on how far the movie will travel on it’s x and y axis so I can’t drag my movie out of the visible screen. How can this be achieved?

```auto
speed = .99; 
setInterval(CursorMovement, 40); 
function CursorMovement() { 
tvmovies._x = speed*(tvmovies._x-_xmouse)+_xmouse; 
tvmovies._y = speed*(tvmovies._y-_ymouse)+_ymouse; 
}

```

Thanks

Eddie
