# Dragable elastic window

**URL:** <https://forum.kirupa.com/t/dragable-elastic-window/209516>\
**Category:** Uncategorized\
**Created:** [December 9, 2006, 5:15pm UTC](https://forum.kirupa.com/t/dragable-elastic-window/209516 "2006-12-09T17:15:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chaoti](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@chaoti](https://forum.kirupa.com/u/chaoti)\
**Post date:** [December 9, 2006, 5:15pm UTC](https://forum.kirupa.com/t/dragable-elastic-window/209516/1 "2006-12-09T17:15:18Z")

</div>

I looked up a new elastic code for flash 8 however it folows the mouse and that is not what i am after, I have tried to fiddle with the code a bit but to no avail. I was wondering if anyone had any suggestions on how to make a movieclip use the elastic function and make it dragable. I want the movieclip to stay where you release the mouse and bounce accordingly.

I tried to find my last post to follow up on the help i recieved regarding the calculating distance within a moving movie clip, but i could not find it. I wish kirupa had a search for the forums.

Here is the code for the elastics i am using:

// ELASTICITY PROTOTYPE  
// Created on the 20th Nov 2006 by DV81  
//  
// This can be extended further but made it for people who don’t want  
// to use the tween classes and want raw math for more control.  
// Note also I know there are 1 million ways to skinning a cat, but I spent almost all  
// day trying to figure this out to work with Flash 8 who knows might come  
// in handy for someone. Enjoy!

MovieClip.prototype.elastic = function(accel, friction) {  
this.dX = 0;  
this.dY = 0;  
this.onEnterFrame = function(){  
this.dX = (this.dX \* friction)+((\_xmouse - this.\_x) \* accel);  
this.dY = (this.dY \* friction)+((\_ymouse - this.\_y) \* accel);  
this.\_x += this.dX;  
this.\_y += this.dY;

```
    // This is added to save resources you can delete or comment out if you 
    // need continuous movement.
    if(Math.abs(this.dX) &lt; 0.01 || Math.abs(this.dY) &lt; 0.01){
        delete this.onEnterFrame;
    }
    //
}

```

}

// USAGE  
// Simply create a movieclip dynamically or manually then call ‘elastic’ function  
mc.elastic(0.1,0.9);

I use a basic “this.onPress and onRelease” type of approach when calling the object but it does not seem to be cooperating no matter what i replace the xmouse and ymouse with.

Help a n00b out?:drool:
