PDA

View Full Version : Radio Button Component Problem - AS 2.0 Flash 8


saikiran
07-21-2006, 07:11 AM
hi to all,

I want to do this in my small quiz which i am making.

I have two radio buttons, named r1 and r2 respectively.

User will select any one of the radio button and press the next button.

Whenever user wants to go back to the previous question, they press the back button, and the option that they already selected should be highlighted.

To do this, what i did is

1) stored the selection in an Array and then wrote a function to check whether the index is true, then i try to re set the same radio button.

I am not getting it as i want. May be some error in my script....

This is the code

//array used to store the radio button selection

var userChoice:Array = [];

//a function to check which radio button instance was selected

function disp_dot():Void
{

if(r1.selection==true)
{
r1.selection=true;
}
if(r2.selection==true)
{
r2.selection=true;
}

}



in the prev. button, i am calling this function

//prev button script

on(release)
{
_root.disp_dot(); // routine called

prevFrame(); //jumped to prev. question

}


can anyone help me out, as i have to finish this assignment quickly

cheers
sai
saisen76@hotmail.com

mooska
07-21-2006, 07:52 AM
First frame var answersTab = [];//array or object
nextBtn.onPress = function(){
nextFrame();
}
stop();

Second framenextBtn.onPress = function(){
answersTab.q1= {sel:this._parent.radioGroup.selection};//this one put answer object into your array, its easier this way, you dont have to iterate hole array to get your answer.
nextFrame();
}
if(answersTab.q1 != undefined){
radioGroup.selection = answersTab.q1.sel;//here we`re assigning selection
}
Third framebackBtn.onPress =function(){
prevFrame();
}

sima
09-12-2007, 10:28 PM
hi everybody!
i have a problem, i want to put psychic tests in my site , but i don't know how i use "IF" statement, that if user selected this rb, give 10 points?!
pls help me;;)
good luck!