Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to sum values of radiobutton groups in actionscript

New Here ,
Nov 07, 2016 Nov 07, 2016

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 .

Untitled.jpg

TOPICS
ActionScript
342
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 07, 2016 Nov 07, 2016

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;

}

}

Translate
Community Expert ,
Nov 07, 2016 Nov 07, 2016

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;

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 09, 2016 Nov 09, 2016

Thank you very much, let me implement this

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 09, 2016 Nov 09, 2016

you're welcome.

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 09, 2016 Nov 09, 2016

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

projectfile for calculator2.zip - Google Drive

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 10, 2016 Nov 10, 2016
LATEST

you're not using the code i suggested.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines