2 Replies Latest reply on Apr 28, 2009 1:34 AM by SujitG

    Text only radio button

    invisibleBlade Level 1

      Hi all,

      I have a RadioButtonGroup and I want each button to simply be a label (no button image) and for the text to be black except for the selected item which should be red. I have managed to get rid of the button graphic but can't find a way to have the text color change to indicate selection.

      Any suggestions?

       

      Cheers

        • 1. Re: Text only radio button
          Gregory Lafrance Level 6

          This code should help. You can set the textSelectionColor and textRollOverColor as desired:

           

          <?xml version="1.0"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
            <mx:Script>
              <![CDATA[
                import mx.controls.RadioButtonGroup;
               
                private function changeFunc(evt:Event):void{
                  var rbg:RadioButtonGroup = evt.currentTarget.group;
                 
                  for(var a:uint=0;a<rbg.numRadioButtons;a++){
                    if(rbg.getRadioButtonAt(a) == evt.currentTarget){
                      rbg.getRadioButtonAt(a).setStyle("color", "0xFF0000");
                      rbg.getRadioButtonAt(a).setStyle("textRollOverColor", "0xFF0000");
                      rbg.getRadioButtonAt(a).setStyle("textSelectionColor", "0xFF0000");
                    }else{
                      rbg.getRadioButtonAt(a).setStyle("color", "0x000000");
                      rbg.getRadioButtonAt(a).setStyle("textRollOverColor", "0x000000");
                      rbg.getRadioButtonAt(a).setStyle("textSelectionColor", "0x000000");
                    }
                  }
                }
              ]]>
            </mx:Script>
            <mx:RadioButton groupName="cardtype" change="changeFunc(event)"
              id="americanExpress" label="American Express" width="150"/>
            <mx:RadioButton groupName="cardtype" change="changeFunc(event)"
              id="masterCard" label="MasterCard" width="150"/>
            <mx:RadioButton groupName="cardtype" change="changeFunc(event)"
              id="visa" label="Visa" width="150"/>
          </mx:Application>

          • 2. Re: Text only radio button
            SujitG Level 2

            Hi,

             

            Please try using a List control. Please find more details at the URL below. Try clicking on "Examples" to view a sample.

             

            http://livedocs.adobe.com/flex/3/langref/mx/controls/List.html

             

            Hope this helps.