I have a flash game that randomly drops balls and you try to catch them however once you win or loose I cant get the balls to stop falling? can anyone see why this is happening?
//random ball fall
allBalls = new Array();
depth = 0;
function makeNewClip() {
clearInterval(ranID);
ran = (Math.random()*1000)+1;
ranID = setInterval(makeNewClip, ran);
newClip = _root.attachMovie('BALL', 'BALL'+depth, depth++);
allBalls.push(newClip);
newClip._x = Math.random()*560;
newClip._y = -50;
newClip.speed = (Math.random()*5)+10;//ball fall speed
newClip.onEnterFrame = function() {
this._y += this.speed;
if (this._y>Stage.height) {
updateScore(-1);
this.removeMovieClip();
for (i=o; i<allBalls.length; i++) {
if (this == allBalls*) {
allBalls.splice(i, 1);
}
}
}
};
}
makeNewClip();
//Glove
_root.attachMovie('Pick', 'pick_mc', -1);
pick_mc._y = _ymouse;
pick_mc._x = _xmouse;
watchKeyboard = new Object();
watchKeyboard.onKeyDown = function() {
if (Key.isDown(KEY.LEFT)) {
pick_mc._x -= 50;
}
if (Key.isDown(KEY.RIGHT)) {
pick_mc._x += 50;
}
};
startDrag("pick_mc", true);
Key.addListener(watchKeyboard);
//Check Collision
_root.createEmptyMovieClip('watchCollision', -2);
pick_mc.onEnterFrame = function() {
for (i=0; i<allBalls.length; i++) {
if (allBalls*.ball_hit.hitTest(_root.pick_mc.hit_me)) {
_root.pick_mc.gotoAndPlay(2);
allBalls*.removeMovieClip();
allBalls.splice(i, 1);
updateScore(1);
}
else {
if(allBalls*.hitTest(floor)) {
allBalls*.removeMovieClip();
allBalls.splice(i, 1);
updateAway(1);
}
}
}
};
score = 0;
away_score = 0;
function updateScore(amount) {
score += amount;
home_txt.text = score;
}
function updateAway(amount) {
away_score += amount;
away_txt.text = away_score;
}
updateScore(0);
updateAway(0);
//check score
onEnterFrame = function () {
if (_root.score == 10) {
newClip.unloadMovie();
trace("You Win");
_root.gotoAndStop("WIN");
}
else{
if (_root.away_score == 10) {
trace("You lose");
newClip.unloadMovie();
_root.gotoAndStop("LOSE");
}
}
};