Reputation: 1203
I have the following codes,
for (i=0; i<answerArray.length; i++) {
var myOptionButton1:spark.components.RadioButton = new spark.components.RadioButton();
myOptionButton1.label = answerArray.getItemAt(i).Answer_Choice;
if (answerArray.getItemAt(i).Correct_Flag == 1) {
myOptionButton1.value = 1;
} else {
myOptionButton1.value = 0;
}
answerItem.addChild(myOptionButton1);
myOptionButton1.group = rbGroup;
}
rbGroup.addEventListener(Event.CHANGE, selectionHandler);
}
rbGroup is the radio button group that holds the radio buttons together. Usually, there would be four radio buttons in this radio button group. In my selectionHandler function, for now, I am only trying to display the label of the selected radio button. event.currentTarget.label seems to be only working for checkboxes. Is there a way to get the label of the selected radio button?
Thanks in advance, Monte
Upvotes: 1
Views: 2313
Reputation: 8050
From FlexExamples:
You could add a listener for the itemClick
event and access the event.Label
property.
<mx:RadioButtonGroup id="radioGroup" itemClick="radioGroup_itemClick(event);" />
private function radioGroup_itemClick(evt:ItemClickEvent):void {
trace(evt.label);
}
Upvotes: 0