Highlighted

Quiz - Retry Action with Counter and If statement

Community Beginner ,
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();

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

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

Views

96

Likes

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

Quiz - Retry Action with Counter and If statement

Community Beginner ,
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();

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

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

Views

97

Likes

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
Apr 28, 2019 1
Adobe Community Professional ,
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.

Likes

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
Reply
Loading...
Apr 28, 2019 0
Community Beginner ,
Apr 29, 2019

Copy link to clipboard

Copied

Check again. The retry_btn is in frame 68.

Likes

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
Reply
Loading...
Apr 29, 2019 0
Adobe Community Professional ,
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?

Likes

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
Reply
Loading...
Apr 29, 2019 0
Community Beginner ,
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.

Likes

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
Reply
Loading...
Apr 29, 2019 0
Adobe Community Professional ,
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();

Likes

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
Reply
Loading...
Apr 30, 2019 2
Community Beginner ,
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();

Likes

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
Reply
Loading...
Apr 30, 2019 0
kglad LATEST
Adobe Community Professional ,
Apr 30, 2019

Copy link to clipboard

Copied

you're welcome.

Likes

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
Reply
Loading...
Apr 30, 2019 0