Frame 1
function poof(x, y, impact) {
attachMovie("poof", "p" + poofCount, poofCount, {_x:x, _y:y, _xscale:impact, _yscale:impact});
poofCount++;
score = score + Math.round(Math.abs(impact / 8));
}
Stage.align = "TL";
Stage.scaleMode = "noscale";
var poofCount = 0;
var score = 0;
stop();
Symbol 3 MovieClip [poof] Frame 5
this.removeMovieClip();
Symbol 6 Button
on (press) {
dragBall();
}
on (release, releaseOutside) {
releaseBall();
}
Symbol 10 MovieClip [ball] Frame 1
#initclip 2
Object.registerClass("ball", ball);
#endinitclip
Symbol 12 MovieClip [__Packages.ball] Frame 0
class ball extends MovieClip
{
var x_velocity, y_velocity, bounce, gravity, friction, wallImpact, rotate, rotateDecay, onEnterFrame, speed0, speed1, speed2, speed3, radius, _width, startDrag, dx, _x, dy, _y, _xmouse, stopDrag, rotatable, lastx, lasty;
function ball () {
super();
x_velocity = (Math.random() * 20) - 10;
y_velocity = (Math.random() * 10) - 5;
bounce = -0.8;
gravity = 2;
friction = 0.95;
wallImpact = -0.8;
rotate = 0;
rotateDecay = 0.9;
onEnterFrame = upkeep;
speed0 = (speed1 = (speed2 = (speed3 = 0)));
radius = _width / 2;
}
function dragBall() {
onEnterFrame = listen;
(startDrag(false, radius, radius, Stage.width - radius, Stage.height - radius));// not popped
dx = _x;
dy = _y;
}
function releaseBall() {
onEnterFrame = upkeep;
y_velocity = dy;
x_velocity = dx;
if ((dy == 0) && (dx == 0)) {
y_velocity = -20;
x_velocity = 25 * (Math.min(Math.abs(_xmouse), _width / 2) / _width);
if (_xmouse > 0) {
x_velocity = x_velocity * -1;
}
}
(stopDrag());// not popped
}
function upkeep() {
y_velocity = y_velocity + gravity;
_y = _y + y_velocity;
_x = _x + x_velocity;
if ((_y + radius) > Stage.height) {
y_velocity = y_velocity * bounce;
_y = Stage.height - radius;
if (y_velocity < -5) {
_root.poof(_x, Stage.height, y_velocity * 4);
}
x_velocity = x_velocity * friction;
if ((x_velocity * rotate) < 0) {
rotate = rotate * -1;
}
rotate = rotate * rotateDecay;
} else if ((_y - radius) < 0) {
y_velocity = y_velocity * bounce;
_y = radius;
if (y_velocity > 5) {
_root.poof(_x, 0, y_velocity * 4);
}
x_velocity = x_velocity * friction;
if ((x_velocity * rotate) < 0) {
rotate = rotate * -1;
}
rotate = rotate * rotateDecay;
}
if ((_x - radius) < 0) {
x_velocity = x_velocity * wallImpact;
_x = radius;
_root.poof(0, _y, x_velocity * 4);
rotate = rotate + 5;
} else if ((_x + radius) > Stage.width) {
x_velocity = x_velocity * wallImpact;
_x = Stage.width - radius;
_root.poof(Stage.width, _y, x_velocity * 4);
rotate = rotate + 5;
}
rotatable._rotation = rotatable._rotation + rotate;
if (Math.abs(x_velocity) < 1) {
x_velocity = 0;
}
if (Math.abs(y_velocity) < 1) {
y_velocity = 0;
}
}
function listen() {
dx = _x - lastx;
dy = _y - lasty;
var _local2 = Math.sqrt((dx * dx) + (dy * dy));
speed3 = speed2;
speed2 = speed1;
speed1 = speed0;
speed0 = _local2;
lastx = _x;
lasty = _y;
}
}