Skip to main content
Dragon_King
Participating Frequently
April 28, 2019
Answered

Quiz - Retry Action with Counter and If statement

  • April 28, 2019
  • 1 reply
  • 656 views

Hi Happy Easter!

I want to make a counter for a Quiz I'm preparing. I want to do this in Frame, where the wrong answer to the question will be given, (Frame 61) becomes the 1st counter of 0. And in the frame that shows the result, that is, that the answer is wrong (Frame 64), I want press a (Retry) button and return to the original Frame of Question (Frame 61). If you can help me. (I have no errors)

My code in Frame 61:

btn_a.addEventListener(MouseEvent.CLICK, correct);

btn_b.addEventListener(MouseEvent.CLICK, wrong);

btn_c.addEventListener(MouseEvent.CLICK, wrong);

btn_d.addEventListener(MouseEvent.CLICK, wrong);

var count = 0;

function correct(event:MouseEvent):void {

     gotoAndStop(64);

}

function wrong(event:MouseEvent):void {

     gotoAndStop(68);

     count = 1;

}

stop();

My code in Frame 64:

next_q.addEventListener(MouseEvent.CLICK, nextAsk);

retry_btn.addEventListener(MouseEvent.CLICK, retry);

function nextAsk(event:MouseEvent):void {

     gotoAndStop(72);

}

function retry(event:MouseEvent):void {

     if(count == 1) {

          gotoAndPlay(61);

     } else {

     gotoAndStop(72);

     }

}

stop();

This topic has been closed for replies.
Correct answer kglad

My next_q button to go next question is working. But i want to give a second chance if i get the wrong answer to try again, but only once in every question.
For retry_btn i don't know how i can to do to work.


use:

code in Frame 61:

btn_a.addEventListener(MouseEvent.CLICK, correct);

btn_b.addEventListener(MouseEvent.CLICK, wrong);

btn_c.addEventListener(MouseEvent.CLICK, wrong);

btn_d.addEventListener(MouseEvent.CLICK, wrong);

var count;

function correct(event:MouseEvent):void {

     gotoAndStop(64);

}

function wrong(event:MouseEvent):void {

     count++;

     gotoAndStop(68);

}

stop();

code in Frame 68

next_q.addEventListener(MouseEvent.CLICK, nextAsk);

retry_btn.addEventListener(MouseEvent.CLICK, retry);

function nextAsk(event:MouseEvent):void {

     gotoAndStop(72);

}

function retry(event:MouseEvent):void {

     if(count == 1) {

          gotoAndPlay(61);

     } else {

     gotoAndStop(72);

     }

}

stop();

1 reply

kglad
Community Expert
Community Expert
April 29, 2019

when the answer's wrong, you go to frame 68, not 64.  it's not clear what's on frame 68 but obviously that's the issue.

Dragon_King
Participating Frequently
April 29, 2019

Check again. The retry_btn is in frame 68.

kglad
Community Expert
Community Expert
April 29, 2019

when on frame 61

if you answer correctly and then click retry does your app work as expected?

if you answer incorrectly and then click retry does your app work as expected?