I can’t seem to figure out how to set the selected state of a RadioButton component to false. As mentioned in the comments here http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/RadioButton.html it has been done by design to ignore the call for false on the RadioButton component! I have tried changing the name of the group for the elements and even doing a removeChild and then addChild again to try and get them to reset to unselected. I had originally wanted to reuse the same elements on stage for each question but the way it looks now I will have to create a set of RadioButtons for each question in my quiz which feels awfully wasteful.
Any ideas how I can go about deselecting RadioButton components?
//does not work
answer1.selected = false;
removeChild(answer1); //successfully removed
addChild(answer1); //returns to the stage with the selected state of true
See a direct snippet from the RadioButton.as file that says you can’t set it to false. :!:
/**
* @private (setter)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
override public function set selected(value:Boolean):void {
// can only set to true in RadioButton:
if (value == false || selected) { return; }
if (_group != null) { _group.selection = this; }
else { super.selected = value; }
}