Copy link to clipboard
Copied
hello all respected members, i am new to actionscript, i want to make a score calculator with radio buttons and radio button groups and want to sum values of selected radio buttons in the score calculator test.Also the risk remarks will bedisplayed according to the value of risks, please help, as i havnt found anything on it .
var obj:Object = {};
var sum:int;
for(var i:int=1;i<=rbNum;i++){
this['rb'+i].addEventListener(MouseEvent.CLICK,f);
}
function f(e:MouseEvent):void{
obj[e.currentTarget.groupName]=e.currentTarget.value;
sum=0
for(var s:String in obj){
sum+=obj;
}
}
Copy link to clipboard
Copied
var obj:Object = {};
var sum:int;
for(var i:int=1;i<=rbNum;i++){
this['rb'+i].addEventListener(MouseEvent.CLICK,f);
}
function f(e:MouseEvent):void{
obj[e.currentTarget.groupName]=e.currentTarget.value;
sum=0
for(var s:String in obj){
sum+=obj;
}
}
Copy link to clipboard
Copied
Thank you very much, let me implement this
Copy link to clipboard
Copied
you're welcome.
(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)
Copy link to clipboard
Copied
stop()
import fl.controls.RadioButton;
import fl.controls.RadioButtonGroup
var rbg1: RadioButtonGroup = new RadioButtonGroup("agegroup");
var wst1: RadioButtonGroup = new RadioButtonGroup("waistgroup");
agea.group = rbg1;
ageb.group = rbg1;
agec.group = rbg1;
waista.group = wst1;
waistb.group = wst1;
waistc.group = wst1;
rbg1.addEventListener(MouseEvent.CLICK, cal);
wst1.addEventListener(MouseEvent.CLICK, cal);
calculate.addEventListener(MouseEvent.CLICK, cal);
function cal(e:MouseEvent)
{
var a:Number= Number(rbg1.selectedData) + Number(wst1.selectedData)
totalscore.text = String(a)
}
this one is helping me to add values from radiobutton groups but strange enough the addition of the values of buttons "wasit1" and "waist2" is displayed as zero
following is the project file
Copy link to clipboard
Copied
you're not using the code i suggested.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now