• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

quiz game with Countdown Timer AS3

Community Beginner ,
Feb 25, 2018 Feb 25, 2018

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);

}

TOPICS
ActionScript

Views

577

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 25, 2018 Feb 25, 2018

this:

gameTimer = new Timer (1000,0);

gameTimer.addEventListener(TimerEvent.TIMER, countDown_4);

executing more than once will usually cause a problem.

Votes

Translate

Translate
Community Expert ,
Feb 25, 2018 Feb 25, 2018

Copy link to clipboard

Copied

LATEST

this:

gameTimer = new Timer (1000,0);

gameTimer.addEventListener(TimerEvent.TIMER, countDown_4);

executing more than once will usually cause a problem.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines