1 Reply Latest reply on Dec 4, 2006 11:03 PM by chris.huston.t10

    radiobutton help

      Is there a way to set a Radio Button so that the user can click on it to select it, then click on it again to deselect it?
        • 1. Re: radiobutton help
          chris.huston.t10 Level 3
          There may be a more elegant way of doing this, but you could add a listener like this:

          private function change_rb(rb:RadioButton):void {
          if (rb.selected) {
          } else {

          private function unselect(evt:MouseEvent):void {
          evt.currentTarget.selected = false;
          evt.currentTarget.group.selection = null;

          You will also need to change the updateText function to this:
          private function updateText():void {
          var totalSelected:uint = 0;
          var cone:String = "";
          var size:String = "";
          if (coneType.selection.selected) {
          cone = coneType.selection.label;
          if (coneSize.selection.selected) {
          size = coneSize.selection.label;
          iceConeTextBox.text = cone + "\r" + size;
          if (totalSelected == 2) {
          next_btn.enabled = true; //for going to next view in viewstack

          Then for each of your radio buttons, set the change event:

          <mx:RadioButton groupName="coneType" id="sugarCone" value="sugarCone"
          label="Sugar Cone" width="150" x="2" y="62" change="change_rb(sugarCone)"/>
          <mx:RadioButton groupName="coneType" id="waffleCone" value="waffleCone"
          label="Waffle Cone" width="150" x="2" y="88" change="change_rb(waffleCone)"/>

          If this isn't what you were looking for, post back.