I have used files from a tutorial on this site to create a very basic quiz that keeps a score.
It works very well but I want to get it so that when the user selects and answer (a,b,c,d) it processes it rather than having a separate button to submit each answer. So that the user makes their choices from the 3 questions then clicks one button to see their score. I appreciate any help I can get, has been a couple years since I had to do any AS3 coding.
There are 2 key frames in the file;
[COLOR=#b22222]AS3 code on first key frame;[/COLOR]
stop();// using the import directive to import the required classes
import fl.controls.RadioButtonGroup;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
// starting out with a score of 0
var myscore = 0; score.text = myscore+"";
// creating a new instance of the radioButtonGroup Class
var mygroup1:RadioButtonGroup = new RadioButtonGroup("group1");
a1.group = a2.group = a3.group = a4.group = mygroup1;
b1.addEventListener(MouseEvent.CLICK, quizHandler1)
function quizHandler1(event:MouseEvent):void{
if(mygroup1.selection.label=="a"){myscore+=10; smiley.visible=true;}
else{ nextFrame(); smiley.visible=false;}
}
var mygroup2:RadioButtonGroup = new RadioButtonGroup("group2");
an1.group = an2.group = an3.group = an4.group = mygroup2;
score.text = myscore+""; // showing updated score
b2.addEventListener(MouseEvent.CLICK, quizHandler2)
function quizHandler2(event:MouseEvent):void{
if(mygroup2.selection.label=="b"){ myscore+=10; smiley.visible=true}
else{ nextFrame(); smiley.visible=false}
}
var mygroup3:RadioButtonGroup = new RadioButtonGroup("group3");
ans1.group = ans2.group = ans3.group = ans4.group = mygroup3;
score.text = myscore+"";
b3.addEventListener(MouseEvent.CLICK, quizHandler3);
function quizHandler3(event:MouseEvent):void{
if(mygroup3.selection.label=="a"){ myscore+=10; nextFrame()}
else{nextFrame() }
}
[COLOR=#b22222]AS3 code on second key frame;[/COLOR]
score.text = myscore+"/30"; // updating the score
if(myscore>=20){smiley.visible=true}
else
{smiley.visible=false}