Search code examples
apache-flexactionscriptradio-button

flex dynamic radio button,how to get the value of selected radio button


I am creating dynamic radion button like this

for(var i:Number=0;i<xml.loc.length();i++)
{
    var radioBtn:RadioButton=new RadioButton();
    radioBtn.x=150;
    radioBtn.y=150;
    radioBtn.label=xml.loc[i];
    countryChoice.addChild(radioBtn);
    radioBtn.addEventListener(MouseEvent.CLICK,radiobuttonclickhandler)

    function radiobuttonclickhandler(event:MouseEvent):void
    {
        //here i need to get the selected radio button value.
         lblname.text=radioBtn.label
    }
}

i need to get the value of labelname in which one is i am selected.how to do?


Solution

  • Dont'use groupName, but group to set radioButton together.

    group is a property which contains a RadioButtonGroup object. This object can know which RadioButton is selected by using selection property.