Hi guys.
I am making a dynamic quiz using PHP, MySQL and XML. Questions are fetched and parsed in flash. I am using radio buttons for multiple choices. Somehow i am unable to trigger the radio buttons events in order to collect the answers for total score. it could be the level problem somehow it is not connecting.
This is my level structure.
PHP Code:
root
questions_mc
question1_mc
radiogroup1
radioBtn1
radioBtn2
radioBtn3
radioBtn4
question2_mc
.
.
questionN_mc
Usually addEventListener works on radio group name. But it is not working. Here is my code.
PHP Code:
var rbListener:Object = new Object();
for (i=0; i<nodes.length; i++){
question = questions_mc.attachMovie("q_mc", "q-"+i+"_mc", questions_mc.getNextHighestDepth(), {_x:15, _y:13+230*i});
question.question_tf.text = i+1+". "+this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
rightAns[i] = this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue;
tempAns[0] = this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue;
tempAns[1] = this.firstChild.childNodes[i].childNodes[2].firstChild.nodeValue;
tempAns[2] = this.firstChild.childNodes[i].childNodes[3].firstChild.nodeValue;
tempAns[3] = this.firstChild.childNodes[i].childNodes[4].firstChild.nodeValue;
//trace_tf.text(tempAns.length);
for(var j=0; j<4; j++){
var x:Number = Math.floor((Math.random()*tempAns.length));
radioButton = question.createClassObject(RadioButton, "ans_"+j, question.getNextHighestDepth(), {label:tempAns[x], data:tempAns[x], groupName:"ans"+i+"group"});
radioButton.move(80,50+rbHeight*j);
rbHeight = radioButton.height+10;
radioButton.setStyle("fontSize", "18");
radioButton.setStyle("color", "0xffffff");
radioButton.setStyle("embedFonts", true);
radioButton.setStyle("fontFamily", "Mix");
radioButton.setSize(1920, 35);
tempAns.splice(x,1);
}
//trace_tf.text = trace_tf.text + " " + radioButton.groupName;
radioGroupsArray[i] = radioButton.groupName;
//radioButton.groupName.addEventListener("click", rbListener);
questions_mc.question.radioGroupArray[i].addEventListener("click", rbListener);
}
rbListener.click = function(evt_obj:Object){
_root.trace_tf.text = "radio";
}
Thanks