# How to Use this Function

**URL:** <https://forum.kirupa.com/t/how-to-use-this-function/156118>\
**Category:** flash\
**Created:** [July 22, 2005, 5:55pm UTC](https://forum.kirupa.com/t/how-to-use-this-function/156118 "2005-07-22T17:55:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![artwisted](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@artwisted](https://forum.kirupa.com/u/artwisted)\
**Post date:** [July 22, 2005, 5:55pm UTC](https://forum.kirupa.com/t/how-to-use-this-function/156118/1 "2005-07-22T17:55:31Z")

</div>

onClipEvent (load) {  
targetX = 2;  
targetY =60;  
vx = 0;  
// our current velocity  
// play with these next to values to get desired amount of springyness  
springSpeed = .2;  
// higher values make spring move faster  
springDamp = .8;  
// lower values make more resistance (friction)  
this.onEnterFrame = function(roll) {  
var diffX = targetX-this.\_x;  
var diffY = targetY-this.\_y;  
vx += diffX_springSpeed;  
vx += diffY_springSpeed;  
vx \*= springDamp;  
this.\_x += vx;  
this.\_y += vx;  
if (Math.abs(diffX)\<1 && Math.abs(diffY)\<1 && Math.abs(vx)\<.1) {  
this.\_x = targetX;  
this.\_y = targetY;  
vx = 0;  
//delete this.onEnterFrame;

```
            }
    };

```

}

Its a spring type effect, it works on enterframe, but hwo can i get ti to work on my rollover?
