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

Quiz - Retry Action with Counter and If statement

Community Beginner ,
Apr 28, 2019 Apr 28, 2019

Copy link to clipboard

Copied

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

Views

273

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 , Apr 30, 2019 Apr 30, 2019

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 nex

...

Votes

Translate

Translate
Community Expert ,
Apr 28, 2019 Apr 28, 2019

Copy link to clipboard

Copied

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.

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
Community Beginner ,
Apr 29, 2019 Apr 29, 2019

Copy link to clipboard

Copied

Check again. The retry_btn is in frame 68.

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
Community Expert ,
Apr 29, 2019 Apr 29, 2019

Copy link to clipboard

Copied

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?

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
Community Beginner ,
Apr 29, 2019 Apr 29, 2019

Copy link to clipboard

Copied

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.

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
Community Expert ,
Apr 30, 2019 Apr 30, 2019

Copy link to clipboard

Copied

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

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
Community Beginner ,
Apr 30, 2019 Apr 30, 2019

Copy link to clipboard

Copied

I find it...Thanks for help!


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:int;

function correct(event:MouseEvent):void

{

     gotoAndStop(64);

}

function wrong(event:MouseEvent):void

{

     count++;

     if(count == 1)

     {

     gotoAndStop(67);

     } else {

          gotoAndStop(70);

     }

}

stop();

Frame 64:

next_q.addEventListener(MouseEvent.CLICK, nextAsk);

function nextAsk(event:MouseEvent):void

{

     gotoAndStop(73);

}

stop();

Frame 67:

retry_btn.addEventListener(MouseEvent.CLICK, retryAsk);

function retryAsk(event:MouseEvent):void

{

     gotoAndPlay(61);

}

stop();

Frame 70:

next_q2.addEventListener(MouseEvent.CLICK, lostAsk);

function lostAsk(event:MouseEvent):void

{

     gotoAndStop(73);

}

stop();

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
Community Expert ,
Apr 30, 2019 Apr 30, 2019

Copy link to clipboard

Copied

LATEST

you're welcome.

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