PDA

View Full Version : [AS2] OR syntax/operator in actionscript


candice
12-17-2008, 01:44 PM
Hi all, im currently developing an application where the user needs to choose from a set of radio buttons. I need to make sure that the user selects one of the choices before going on to the next page. Attached below is my code:


next_btn.onRelease = function(){

if(paint_1.selected == false || paint_2.selected == false || paint_3.selected == false){
error_txt.text = "Please select one of the choices before proceeding to the next stage";
}
else{
gotoAndPlay("Scene 3");
}



}



I need to use the OR syntax in flash to integrate it into the if/else statement, but somehow the statement doesnt work. Can anyone help me?

jasonJ
12-17-2008, 02:01 PM
Did you assign each of your radio buttons to the same group? Eg.:

paint_1.groupName = "myRadioGroup";
paint_2.groupName = "myRadioGroup";
paint_3.groupName = "myRadioGroup";


Use this when you want to display the error msg when no radio button is selected.
if (!paint_1.selected && !paint_2.selected && !paint_3.selected) {
error_txt.text = "Please select one of the choices before proceeding to the next stage";
}