1 Reply Latest reply on Sep 14, 2009 8:24 AM by michael nieuwenhuizen

    RadioButtonGroup: selectedValue delayed

    michael nieuwenhuizen Level 1

      Hello, I'm using the code below, but the listener seems to show a delayed result.  When I press a radioButton the selectedValue of the radioButtonGroup comes out as the radioButton I have selected before, and not 1 but 2 of the radioButtons have the property "selected" as true.  What am I doing wrong?

       

          private function initRBGroup():void {
              this.rbGroup = new  RadioButtonGroup();
              this.rb = new Array();
              var form:Form =  new Form();
              for (var i:int=0; i<4; i++) {
                   this.rb[i] = new RadioButton();
                  this.rb[i].group =  this.rbGroup;
                  this.rb[i].label = String(i);
                   this.rb[i].addEventListener(Event.CHANGE, changeListener);
                   form.addChild(this.rb[i]);
              }
              this.addChild(form);
           }

       

          private function changeListener(e:Event):void {
              var  s:String = "selected:\n";
              for (var i:int=0; i<4; i++)  {
                  s += " " + String(i) + ": " + String(this.rb[i].selected) +   "\n";
              }
              s += "selectedValue: " +  String(this.rbGroup.selectedValue);
              Alert.show(s);
          }