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

I'm doing a quiz but the result of the quiz is doubled. here's the code

New Here ,
Dec 21, 2021 Dec 21, 2021

Copy link to clipboard

Copied

stop();

var Mark:int = 0;

btn_start.addEventListener(MouseEvent.CLICK, startquiz);

function startquiz(e:MouseEvent) : void {
gotoAndStop("q1")
}

function right_ans(next_question:String) : Function {
return function(e:MouseEvent) : void{
Mark++;
gotoAndStop(next_question);
}
}

function wrong_ans(next_question:String) : Function {
return function(e:MouseEvent) : void{

gotoAndStop(next_question);
}
}

TOPICS
ActionScript , Code , Error

Views

133

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 ,
Dec 22, 2021 Dec 22, 2021

Copy link to clipboard

Copied

why are you returning a function instead of using:

 

function right_ans(next_question:String) : void {
Mark++;
gotoAndStop(next_question);
}

function wrong_ans(next_question:String) : void {
gotoAndStop(next_question);
}

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
New Here ,
Dec 22, 2021 Dec 22, 2021

Copy link to clipboard

Copied

Cause i put code for the question in the next frame.

q1_r.addEventListener(MouseEvent.CLICK, right_ans("q2"));

q1_w0.addEventListener(MouseEvent.CLICK, wrong_ans("q2"));

q1_w1.addEventListener(MouseEvent.CLICK, wrong_ans("q2"));

q1_w2.addEventListener(MouseEvent.CLICK, wrong_ans("q2"));

 

removing the return function breaks it

Scene 1, Layer 'AS3', Frame 332, Line 1, Column 41 1067: Implicit coercion of a value of type void to an unrelated type Function.

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 ,
Dec 23, 2021 Dec 23, 2021

Copy link to clipboard

Copied

LATEST

what code are you using that triggered that 1067 error message?

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