# Elasticity Function in MX

**URL:** <https://forum.kirupa.com/t/elasticity-function-in-mx/41636>\
**Category:** flash\
**Created:** [January 31, 2004, 10:18am UTC](https://forum.kirupa.com/t/elasticity-function-in-mx/41636 "2004-01-31T10:18:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![optimis](https://avatars.discourse-cdn.com/v4/letter/o/ac91a4/32.png) [@optimis](https://forum.kirupa.com/u/optimis)\
**Post date:** [January 31, 2004, 10:18am UTC](https://forum.kirupa.com/t/elasticity-function-in-mx/41636/1 "2004-01-31T10:18:21Z")

</div>

Hi does anyone know how to write an elasticity function in MX?

This works in 5 - but I want to use dynamic masking also - here’s the code (slightly modified from Ilyas Usal. Ilyas is also known as ilyaslamasse )

MovieClip.prototype.move = function (centerx,centery,inertia,k) {

```
x = -this._x + centerx ;
y = -this._y + centery ;

xp = xp * inertia + x*k ;
yp = yp * inertia + y*k ;

_x += xp ;
_y += yp ;

```

}

this goes in the movieclip:

onClipEvent (load) {  
newx = this.\_x;  
newy = this.\_y;

}

onClipEvent (enterFrame) {

```
this.move (newx,newy,0.45,0.5);

```

}

then you can set newx and newy how ever you want buttons or timeline.

I need it to work in MX - any suggestions?

-DWC
