rendered paste bodyvar numberBall:Number = 0;
var numberChar:Number = 0;
var x;
var y;
var myBall;
var myOtherBall;
createEmptyMovieClip("loveSpuds",getNextHighestDepth());
createEmptyMovieClip("balls",getNextHighestDepth());
createEmptyMovieClip("chars",getNextHighestDepth());
function randSize(min:Number, max:Number):Number {
var randomN:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomN;
}
function createBall() {
d = balls.getNextHighestDepth();
e = balls.attachMovie("ball", "ball"+d, d, {_x:_xmouse, _y:_ymouse});
e._height = e._width=randSize(20, 30);
e.fall();
}
loveSpuds.onEnterFrame = function() {
for (v in balls) {
myBall = balls[v];
for (x in chars) {
myChar = chars[x];
if (myBall.hitTest(myChar) && myBall != myChar && myBall._y == 180) {
myChar.removeMovieClip();
numberChar--;
}
}
}
};
MovieClip.prototype.fall = function() {
this.gravity = 8;
this.ac = 1;
this.time = getTimer()/100;
this.floor = 180;
this.bounds = this.getBounds(_root);
this.height = this.bounds.yMax-this.bounds.yMin;
this.width = this.bounds.xMax-this.bounds.xMin;
this.mass = 30/(this.height*this.width);
if (String(this.mass).charAt(2) == "0") {
this.mass *= 6;
}
if (Number(String(this.mass).charAt(2))<3) {
this.mass += 0.1;
}
this.bounce = this.mass*1.2;
this.speedx = 0;
this.speedystart = -30;
this.bounceTime = 0;
this.initalH = this._height;
this.onEnterFrame = function() {
if (this.speedy == 0) {
numberBall--;
this.removeMovieClip();
}
this.timenow = getTimer()/100;
if (this.speedy != 0) {
this.speedy = this.gravity*(this.timenow-this.time)+this.speedystart;
}
this._x += this.speedx/5;
this._y += this.speedy/5;
if (this._y>this.floor) {
if (this.hitTest(c)) {
c.removeMovieClip();
numberChar--;
}
if (this.speedy<6) {
this.removeMovieClip();
numberBall--;
} else if (this.speedy != 0) {
this.bounceTime++;
if (String(this.mass).charAt(2) == "0") {
this._height -= this.ac-5;
} else {
this._height -= this.ac;
}
this.ac *= 3.5;
this._y = this.floor;
if (this.bounceTime == 3) {
this.ac = 1;
this.bounceTime = 0;
this._height = this.initalH;
this.bounce /= 1.00001;
this.speedy *= -this.bounce;
this.time = getTimer();
this.time /= 100;
this.speedystart = this.speedy;
}
}
}
};
};
function setGo(char, number) {
if (numberChar != number) {
f = chars.getNextHighestDepth();
c = chars.attachMovie(char, char+f, f, {_x:360, _y:180});
c.onEnterFrame = function() {
if (this._x != -20) {
this._x -= 2;
} else {
this.removeMovieClip();
numberChar--;
}
};
}
}
function toGo(min, max, char, number) {
counter = randSize(min, max);
onEnterFrame = function () {
if (--counter == 0) {
counter = randSize(min, max);
setGo(char,number);
}
};
}
toGo(40,100,"char",4);
onMouseDown = function () {
if (numberBall != 4) {
createBall();
numberBall++;
}
};