In Flex, how do I deselect all radio buttons in a group?
apache-flex, radio-button
Solution
You need to group all of the radio buttons into a RadioButtonGroup and then set the group selection to null:
<mx:RadioButtonGroup id="myGroup" />
<mx:RadioButton label="One" groupName="myGroup" />
<mx:RadioButton label="Two" groupName="myGroup" />
<mx:RadioButton label="Three" groupName="myGroup" />
<mx:Button label="Clear" click="myGroup.selection = null;" />
Problem
In Flex, sometimes when you need to clear a form you run into the problem that radio button groups seem to defy clearing: try as you might, setting selected=false on all buttons, setting selection=null on the group, doing both, doing them twice, etc., you always seem to end up with one pesky little radio button that's still selected. How do you solve this and restore the radio button group to its initial no-selection state?