Skip to main content
Participant
April 28, 2011
Answered

Radio Button Quiz Problem!

  • April 28, 2011
  • 1 reply
  • 882 views

Hi everyone,

I'm trying to make a basic true/false quiz in Flash.

It involves a question with two radio buttons with instance names t1 and f1 (true and false).

When the user presses check answers a movieclip with instance name yn1 moves to frame 2 or 3 which displays a tick or cross.

This is all working fully, the problem arises if the user presses check answers again.

This for some reason turns the ticks to crosses and the crosses to ticks and I have no idea why!?

My code is as follows:

import flash.events.MouseEvent; stop(); checkAns.addEventListener(MouseEvent.CLICK, checkAnswers); function checkAnswers (Event:MouseEvent):void {      if (t1.selected==true)           {                yn1.gotoAndPlay("true");           }      else           {                yn1.gotoAndPlay("false");           }

     if (t2.selected==true)           {                yn2.gotoAndPlay("true");           }      else           {                yn2.gotoAndPlay("false");           }

     if (f3.selected==true)           {                yn3.gotoAndPlay("true");           }      else           {                yn3.gotoAndPlay("false");           }

     if (f4.selected==true)           {                yn4.gotoAndPlay("true");           }      else           {                yn4.gotoAndPlay("false");           }            }

Apologies if its a completely simple error, I'm very new to flash.

Thanks!!!

This topic has been closed for replies.
Correct answer Ned Murphy

Use gotoAndStop instead of gotoAndPlay

Also, not a problem, but when you test a boolean value in a conditional you don't need to use the ==... as in...

if (f4.selected)

 


1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
April 28, 2011

Use gotoAndStop instead of gotoAndPlay

Also, not a problem, but when you test a boolean value in a conditional you don't need to use the ==... as in...

if (f4.selected)

 


Participant
April 28, 2011

Thank you so much! :-)

Ned Murphy
Legend
April 28, 2011

You're welcome