Skip navigation
Currently Being Moderated

Unselect RadioButton

Dec 2, 2006 7:33 AM


I am having trouble unselecting the RadioButton, i.e. I've got a RadioButtonGroup & 2 RadioButtons. RadioButtonGroup property selectedValue initially equals null and both buttons are unselected. As soon as I select any RadioButton by mouse click I can't unselect it using selectedValue property.

Has anybody had the same problem ?

  • Currently Being Moderated
    Dec 2, 2006 7:44 AM   in reply to Mitek17
    Assuming your radio button group has an id= RadioButtonGroup, then this will unselect the currently selected radio button.

    RadioButtonGroup.selection.selected = false;

    Mark as:
  • Currently Being Moderated
    Dec 2, 2006 5:03 PM   in reply to Mitek17
    You could make a button to unselect your radio group:

    <mx:Button x="165" y="293" label="Unselect" click="RadioButtonGroup.selection.selected = false"/>

    Mark as:
  • Currently Being Moderated
    Feb 17, 2007 9:31 PM   in reply to chris.huston.t10
    OK, my issue is this, I have a selected radio button and when the user press that button again, I want to unselect it. the problem I am having is that the RadioButtonGroup does not generate an event for me to respond with the unselect. Any ideas?
    Mark as:
  • Currently Being Moderated
    Feb 18, 2007 8:03 PM   in reply to Mitek17
    OK fellas,

    I wrote this customized two radio button component that will allow me to unselect the "Selected" radio button just by clicking on it again. Say you click on radiobutton "Yes". Then you click on it again, it will unselect. Please test this and give any feedback to help improve the code. Thanks for your replies in advance:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Box xmlns:mx="" width="118" height="24" direction="horizontal" borderStyle="inset" xmlns:Components="Components.*">

    import mx.controls.Alert;

    var currentSelectionValue:String = null;

    private function handleClick(event:MouseEvent):void
    //Just return if the component is disabled
    if (!enabled) return;

    if ( event.currentTarget.value == currentSelectionValue )
    currentSelectionValue = null; = null;
    currentSelectionValue = event.currentTarget.value;

    <mx:RadioButtonGroup id="yesNoRadioButton" labelPlacement="right" />
    <mx:RadioButton label="Yes" id="yesButton" value="Y" groupName="yesNoRadioButton" click="handleClick(event)" />
    <mx:RadioButton label="No" id="noButton" value="N" groupName="yesNoRadioButton" click="handleClick(event)" width="44"/>
    <mx:RadioButton id="nullSelection" groupName="yesNoRadioButton" visible="false" width="0" />

    Mark as:
  • Currently Being Moderated
    Mar 25, 2008 6:58 AM   in reply to emack06
    emack06: THANK YOU! You had the best answer to my issue, it was simple yet I didn't think of it.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points