# Elasticity Prototype for Flash 8 Users

**URL:** <https://forum.kirupa.com/t/elasticity-prototype-for-flash-8-users/207636>\
**Category:** open source\
**Created:** [November 20, 2006, 6:04am UTC](https://forum.kirupa.com/t/elasticity-prototype-for-flash-8-users/207636 "2006-11-20T06:04:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DV81](https://avatars.discourse-cdn.com/v4/letter/d/b5a626/32.png) [@DV81](https://forum.kirupa.com/u/DV81)\
**Post date:** [November 20, 2006, 6:04am UTC](https://forum.kirupa.com/t/elasticity-prototype-for-flash-8-users/207636/1 "2006-11-20T06:04:50Z")

</div>

Hey guys just thought i’de share something I learnt today !  
It uses \_xmouse and \_ymouse but can be adapted to your OWN targets for X and Y just  
let me know if you need a hand, once again i know it’s not much but just was in a giving mood ! thanks guys

Bass

```auto

// 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) < 0.01 || Math.abs(this.dY) < 0.01){
            delete this.onEnterFrame;
        }
        //
    }
} 

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

```
