# Pan with speed

**URL:** <https://forum.kirupa.com/t/pan-with-speed/285605>\
**Category:** flash\
**Created:** [April 2, 2009, 8:43pm UTC](https://forum.kirupa.com/t/pan-with-speed/285605 "2009-04-02T20:43:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel\_mihalcea](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@daniel\_mihalcea](https://forum.kirupa.com/u/daniel_mihalcea)\
**Post date:** [April 2, 2009, 8:43pm UTC](https://forum.kirupa.com/t/pan-with-speed/285605/1 "2009-04-02T20:43:38Z")

</div>

How to add speed to my pan? This is my code:  
main.onPress = function() {  
main.startDrag();  
detect();  
}

```
main.onRelease = function() {
    this.stopDrag();
}

```

function detect(){  
main.onMouseMove = function() {  
main.onEnterFrame = function(){  
if (main.\_x \>= stroke.\_x){  
main.\_x = stroke.\_x;  
delete main.onEnterFrame;  
}  
if (main.\_y \>= stroke.\_y) {  
main.\_y = stroke.\_y;  
delete main.onEnterFrame;  
}  
if (main.\_x \<= (stroke.\_x - stroke.\_width/2)) {  
main.\_x = stroke.\_x - stroke.\_width/2;  
delete main.onEnterFrame;  
}  
if (main.\_y \<= (stroke.\_y - stroke.\_height/2)) {  
main.\_y = stroke.\_y - stroke.\_height/2;  
delete main.onEnterFrame;  
}  
}  
}  
}

I really don’t know where to put it.  
Thank you.
