1 Reply Latest reply on Nov 8, 2006 8:00 PM by doug777

    Problem with RadioButton

    doug777 Level 1
      The following code works correctly.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" creationComplete = "initApp()">
      <mx:Script>
      <![CDATA[
      import mx.containers.HBox;
      import mx.controls.RadioButton;
      import mx.controls.RadioButtonGroup;
      import mx.collections.ArrayCollection;
      import flash.events.MouseEvent;

      public function initApp():void{
      var hb1:HBox = new HBox();
      page.addChild(hb1);
      var stbg:RadioButtonGroup = new RadioButtonGroup();
      var stbgq:RadioButton = new RadioButton();
      stbgq.groupName = "stbg";
      stbgq.labelPlacement = "left";
      stbgq.label = "Quick Search";
      stbgq.name = "cstbgq";
      stbgq.addEventListener(MouseEvent.CLICK, clickChange);
      stbgq.selected = true;
      var stbgf:RadioButton = new RadioButton();
      stbgf.groupName = "stbg";
      stbgf.labelPlacement = "left";
      stbgf.label = "Full Search";
      stbgf.name = "cstbgf";
      stbgf.addEventListener(MouseEvent.CLICK, clickChange);
      hb1.addChild(stbgq);
      hb1.addChild(stbgf);
      }

      private function clickChange(event:MouseEvent):void{
      //code here in the real file
      }
      ]]>
      </mx:Script>

      But when I include this in a larger file, the bullet in the selected radio button is not present. I can see from the debugger that stbgq.selected is set to true and the program proceeds correctly. So the problem is only that the bullet has not been painted. Clicking the button causes the bullet to appear.

      I have tried including this snippet in several different larger files and sometimes the problem occurs and sometimes it doesn't. But I can't find out what other element(s) in the problem files is causing the problem. The variables for the radio buttons and the group definitely do not appear anywhere else in any file and are in any case local to the function they are in (in the real file).

      Can anyone suggest a workaround for this or is this a bug.

      Doug
        • 1. Re: Problem with RadioButton
          doug777 Level 1
          The apparent randomness of the problem is not correct. In fact it only occurs the first time this routine is called in a project where the routine is called more than once.

          It seems that the problem is linked to labelPlacement. If this line is removed, the button appears with a bullet the same color as the surrounding circle. Clicking it once turns the bullet black.

          Anyone got any ideas?

          Doug