I found this in my old file archive, figured I’d give it to you guys to mess around with. The code is pretty intuitive as far as naming conventions go… enjoy ;).

```
var ballCount:Number = 0;
var GRAVITY:Number = 0.98;
var BOUNCE:Number = -0.9;
var MAX_VELOCITY:Number = 5;
var left:Number = 0;
var top:Number = 0;
var right:Number = Stage.width;
var bottom:Number = Stage.height;
var myBall:MovieClip = createBall();
myBall.vx = 0;
myBall.vy = 0;
myBall.radius = myBall._width/2;
myBall.oldX = 0;
myBall.oldY = 0;
myBall.onEnterFrame = fall;
myBall.onPress = throwBall;
myBall.onRelease = myBall.onReleaseOutside = drop;
myBall._x = Math.random() * right - left;
myBall._y = bottom;
function calculateVelocity()
{
var dx:Number = this._x - this.oldX;
var dy:Number = this._y - this.oldY;
this.vx = Math.min(MAX_VELOCITY, dx);
this.vy = Math.min(MAX_VELOCITY, dy);
this.oldX = this._x;
this.oldY = this._y;
}
function drag()
{
this._x = _xmouse;
this._y = _ymouse;
updateAfterEvent();
}
function throwBall()
{
this.oldX = this._x;
this.oldY = this._y;
delete this.onEnterFrame;
this.onEnterFrame = calculateVelocity;
this.onMouseMove = drag;
}
function drop()
{
delete this.onMouseMove;
this.onEnterFrame = fall;
}
function fall()
{
this.vy += GRAVITY;
this._y += this.vy;
this._x += this.vx;
if (this._x - this.radius < left)
{
this._x = left + this.radius;
this.vx *= BOUNCE;
} else if (this._x + this.radius > right)
{
this._x = right - this.radius;
this.vx *= BOUNCE;
}
if (this._y + this.radius > bottom)
{
this._y = bottom - this.radius;
this.vy *= BOUNCE;
}
}
function createBall() : MovieClip
{
var mc:MovieClip = this.createEmptyMovieClip("ball" + ballCount, ballCount);
mc.lineStyle(10, 0x0, 100);
mc.lineTo(0, 1);
ballCount++;
return mc;
}
```

I’ll still have fun with this thing, even all this time later. Take Care.

_Michael