Elasticity Prototype for Flash 8 Users

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


// 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;

// Simply create a movieclip dynamically or manually then call 'elastic' function