Instance of Symbol 2 MovieClip [Particle] "Starter" in Frame 1
onClipEvent (load) {
firstSpawn = true;
}
Symbol 2 MovieClip [Particle] Frame 1
#initclip 2
Object.registerClass("Particle", Ball);
#endinitclip
Symbol 3 MovieClip [__Packages.Ball] Frame 0
class Ball extends MovieClip
{
var X, _x, Y, _y, onPress, onEnterFrame, onLoad, i, currentParticle, swapDepths, removeMovieClip, randNeg, gravity, randX, randY;
function Ball () {
super();
X = _x;
Y = _y;
onPress = function () {
this.explode(50);
};
onEnterFrame = function () {
this.fall();
};
onLoad = function () {
this.i = 0;
if (!_root.Starter.firstSpawn) {
this.randX = Math.ceil((Math.random() * 10) + 1) * this.getNeg();
this.randY = Math.ceil((Math.random() * 10) + 1) * this.getNeg();
} else {
this.randX = 0;
this.randY = 0;
}
this.gravity = 0;
};
}
function explode(numParticles) {
_root.Starter.firstSpawn = false;
(i);// not popped
while (i < numParticles) {
currentParticle = _root.attachMovie("Particle", "particle_" + i, _root.getNextHighestDepth());
currentParticle._x = X;
currentParticle._y = Y;
i++;
}
swapDepths(_root.getNextHighestDepth());
removeMovieClip();
}
function getNeg() {
randNeg = Math.random();
if (randNeg < 0.5) {
return(-1);
}
return(1);
}
function fall() {
if (gravity < 30) {
gravity = gravity + 0.3;
}
_x = _x + randX;
_y = _y + (randY + gravity);
X = _x;
Y = _y;
}
}