# Drag a clip with intertia

**URL:** <https://forum.kirupa.com/t/drag-a-clip-with-intertia/239851>\
**Category:** flash\
**Created:** [September 26, 2007, 4:15pm UTC](https://forum.kirupa.com/t/drag-a-clip-with-intertia/239851 "2007-09-26T16:15:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaronshekey](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@aaronshekey](https://forum.kirupa.com/u/aaronshekey)\
**Post date:** [September 26, 2007, 4:15pm UTC](https://forum.kirupa.com/t/drag-a-clip-with-intertia/239851/1 "2007-09-26T16:15:08Z")

</div>

I found this in the archives here at Kirupa but am having trouble applying this to my movieclip.

```auto
MovieClip.prototype.inertialDrag = function(ratio, decel) {
var x, y, xspeed, yspeed, drag;
this.onEnterFrame = function() {
if (!drag) {
this._x += xspeed *= decel;
this._y += yspeed *= decel;
} else {
x = this._x;
y = this._y;
this._x = this._parent._xmouse;
this._y = this._parent._ymouse;
}
};
this.onPress = function() {
drag = true;
};
this.onRelease = this.onReleaseOutside=function () {
drag = false;
xspeed = (this._x-x)*ratio;
yspeed = (this._y-y)*ratio;
};
};
// usage
myMovieClip.inertialDrag(.1, .95);

```

How do I actually apply these actions to my movieclip? I tried imagecontainer.intertialDrag… but that didn’t work. Also, it’s complaining about assigning variables with the name x and y. Anyone wanna help me out?
