I'm a newby flash user, I started reading AS3 3.0 Cookbook and some other tutorials here in NG ... I decided to created a game where balls are falling down and the player must click on it to score causing the ball to go to a random place then fall back again ( repeat )
My problem is after my 5 lives are spent ( with life graphics ) I don't know how to stop / pause the game .... the timer for the falling balls continues and my GAMEOVER screen just blinked for a second then disappeared O_o ...
Here's my Code for my game ( its incomplete as I've just started an hour ago ) ...
* Please also give comments and advice about how I program since I hardly know anything yet ...
var myScore:uint=0;
var myKills:uint=0;
var life:uint=5;
// Blue Ball
var blueBall_timer:Timer=new Timer(7,0);
blueBall_timer.addEventListener(TimerEve nt.TIMER, startBlueBall_mc);
blueBall_timer.start();
blueBall_mc.addEventListener(MouseEvent.
CLICK, gameScore);
function gameScore(event:MouseEvent):void {
myScore+=300;
myKills+=1;
myScore_txt.text=" "+myScore;
myKills_txt.text=" "+myKills;
}
function startBlueBall_mc(event:TimerEvent):void {
gameOver_mc.visible=false;
blueBall_mc.y++;
if (blueBall_mc.y>lowerBoundary_mc.y) {
blueBall_mc.y=-50;
blueBall_mc.x=Math.random()*300;
life--;
if (life==4) {
removeChild(lifeFive_mc);
}
if (life==3) {
removeChild(lifeFour_mc);
}
if (life==2) {
removeChild(lifeThree_mc);
}
if (life==1) {
removeChild(lifeTwo_mc);
}
if (life==0) {
gameOver_mc.visible=true;
removeChild(lifeOne_mc);
addChild.(gameOver_mc);
blueBall_timer.stop();
redBall_timer.stop();
}
}
blueBall_mc.addEventListener(MouseEvent.
CLICK, blueHit);
function blueHit(event:MouseEvent):void {
blueBall_mc.y=-50;
blueBall_mc.x=Math.random()*200;
}
}
//Red Ball
var redBall_timer:Timer=new Timer(5,0);
redBall_timer.addEventListener(TimerEven t.TIMER, startRedBall_mc);
redBall_timer.start();
function startRedBall_mc(event:TimerEvent):void {
redBall_mc.y++;
redBall_mc.addEventListener(MouseEvent.C LICK, redHit);
function redHit(event:MouseEvent):void {
redBall_mc.y=-50;
redBall_mc.x=Math.random()*300;
}
if (redBall_mc.y>lowerBoundary_mc.y) {
redBall_mc.y=-50;
redBall_mc.x=Math.random()*400;
}
}