Copy link to clipboard
Copied
hi
i created quiz game with score and limit time for every question.
i don't get any error but when i reach question 4 the timer get crazy and play 10, 7, 4, 1...
this is the code of question 4
please help
stop();
scoretext.text = score.toString();
q4.visible = true;
q4a.visible = true;
q4b.visible = true;
q4c.visible = true;
wrong.visible = false;
right.visible = false;
timeIsUp.visible = false;
nextbutton.visible = false;
q4a.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_204);
function fl_ClickToGoToAndStopAtFrame_204(event:MouseEvent):void
{
q4.visible = true;
q4a.visible = true;
q4b.visible = true;
q4c.visible = true;
wrong.visible = true;
right.visible = false;
nextbutton.visible = true;
gameTimer.removeEventListener(TimerEvent.TIMER, countDown_4);
}
q4b.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_304);
function fl_ClickToGoToAndStopAtFrame_304(event:MouseEvent):void
{
q4.visible = true;
q4a.visible = true;
q4b.visible = true;
q4c.visible = true;
wrong.visible = true;
right.visible = false;
nextbutton.visible = true;
gameTimer.removeEventListener(TimerEvent.TIMER, countDown_4);
}
q4c.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_404);
function fl_ClickToGoToAndStopAtFrame_404(event:MouseEvent):void
{
q4.visible = true;
q4a.visible = true;
q4b.visible = true;
q4c.visible = true;
wrong.visible = false;
right.visible = true;
nextbutton.visible = true;
score = score +5;
gameTimer.removeEventListener(TimerEvent.TIMER, countDown_4);
}
timeleft=10;
timerbox.text=timeleft.toString();
gameTimer = new Timer (1000,0);
gameTimer.addEventListener(TimerEvent.TIMER, countDown_4);
function countDown_4 (e:TimerEvent): void {
timeleft--;
timerbox.text= timeleft.toString();
if(timeleft<1){
timeIsUp.visible = true;
nextbutton.visible = true;
gameTimer.removeEventListener(TimerEvent.TIMER, countDown_4);
}
}
gameTimer.start();
nextbutton.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_504);
function fl_ClickToGoToAndStopAtFrame_504(event:MouseEvent):void
{
gotoAndStop(6);
}
this:
gameTimer = new Timer (1000,0);
gameTimer.addEventListener(TimerEvent.TIMER, countDown_4);
executing more than once will usually cause a problem.
Copy link to clipboard
Copied
this:
gameTimer = new Timer (1000,0);
gameTimer.addEventListener(TimerEvent.TIMER, countDown_4);
executing more than once will usually cause a problem.