rendered paste bodyfunction sendBall(){
var ballPos:int;
switch(currentLevel){
case 1:
ballPos = Math.ceil(Math.random() * (8 - 1 + 1));
break;
case 2:
switch(posDuper){
case 0: ballPos = Math.ceil(Math.random() * (4 - 1 + 1)); posDuper = 1; break;
case 1: ballPos = 4 + Math.ceil(Math.random() * (8 - 5 + 1)); posDuper = 0; break;
}
break;
case 3:
switch(posDuper){
case 0: ballPos = Math.ceil(Math.random() * (3 - 1 + 1)); posDuper = 1; break;
case 1: ballPos = 3 + Math.ceil(Math.random() * (5 - 4 + 1)); posDuper = 0; break;
case 2: ballPos = 5 + Math.ceil(Math.random() * (8 - 6 + 1)); posDuper = 0; break;
}
break;
}
var ballColor:int = Math.ceil(Math.random() * (4 - 1 + 1));
switch(ballColor){
case 1: this["ball" + ballCount] = new BlueBall(); break;
case 2: this["ball" + ballCount] = new RedBall(); break;
case 3: this["ball" + ballCount] = new YellowBall(); ;break;
case 4: this["ball" + ballCount] = new GreenBall(); break;
}
switch(ballPos){
case 1:
this["ball" + ballCount].x = 5;
this["ball" + ballCount].y = 58;
addChild(this["ball" + ballCount]);
break;
case 2:
this["ball" + ballCount].x = 190;
this["ball" + ballCount].y = 58;
addChild(this["ball" + ballCount]);
break;
case 3:
this["ball" + ballCount].x = 355;
this["ball" + ballCount].y = 58;
addChild(this["ball" + ballCount]);
break;
case 4:
this["ball" + ballCount].x = 355;
this["ball" + ballCount].y = 192;
addChild(this["ball" + ballCount]);
break;
case 5:
this["ball" + ballCount].x = 355;
this["ball" + ballCount].y = 356;
addChild(this["ball" + ballCount]);
break;
case 6:
this["ball" + ballCount].x = 190;
this["ball" + ballCount].y = 356;
addChild(this["ball" + ballCount]);
break;
case 7:
this["ball" + ballCount].x = 5;
this["ball" + ballCount].y = 356;
addChild(this["ball" + ballCount]);
break;
case 8:
this["ball" + ballCount].x = 5;
this["ball" + ballCount].y = 192;
addChild(this["ball" + ballCount]);
break;
}
ballCount++; //increment balls
//trace(this["ball" + ballCount] as EventDispatcher);
//(this["ball" + ballCount] as EventDispatcher).addEventListener(MouseEvent.CLICK, function grar(){});
//this["ball" + ballCount].addEventListener(MouseEvent.CLICK, function grar(){});
}