5 Replies Latest reply on Jul 3, 2006 9:08 AM by rmorgan

    RadioButtonGroup

    rmorgan Level 1
      Is it possible to have two radiobutton groups with the same name? If so, could someone tell me how. I will paste the code below, it might be easier show what I am want than explain it. Thanks.

      <mx:State name="newrenewal">
      <mx:SetProperty target="{panel1}" name="height" value="766"/>
      <mx:SetProperty target="{panel2}" name="y" value="459"/>
      <mx:SetProperty target="{panel3}" name="y" value="370"/>
      <mx:AddChild relativeTo="{canvas1}" position="lastChild">
      <mx:Panel x="10" y="126" width="618" height="236" layout="absolute" id="newrenewal" title="UK Alumni Association Membership Dues">
      <mx:RadioButtonGroup id="AssociationDues"/>
      <mx:RadioButton x="10" y="0" label="Student/Recent Graduate Annual Single $20.00*" groupName="AssociationDues"/>
      <mx:RadioButton x="10" y="24" label="Student/Recent Graduate Annual Joint $25.00*" groupName="AssociationDues"/>
      <mx:RadioButton x="10" y="48" label="Annual Single $40.00" groupName="AssociationDues"/>
      <mx:RadioButton x="10" y="72" label="Annual Joint $45.00" groupName="AssociationDues"/>
      <mx:RadioButton x="10" y="96" label="Life Single (One Payment) $700.00" groupName="AssociationDues"/>
      <mx:RadioButton x="10" y="120" label="Life Joint (One Payment) $825.00" groupName="AssociationDues"/>
      <mx:RadioButton x="10" y="144" groupName="AssociationDues">
      <mx:label>Life Single $800.00 (in 5 annual payments of $160.00)</mx:label>
      </mx:RadioButton>
      <mx:RadioButton x="10" y="168" groupName="AssociationDues">
      <mx:label>Life Joint $900.00 (in 5 annual payments of $180.00)</mx:label>
      </mx:RadioButton>
      </mx:Panel>
      </mx:AddChild>
      <mx:SetProperty target="{vbox1}" name="y" value="11"/>
      <mx:SetProperty target="{tabnavigator1}" name="height" value="712"/>
      <mx:SetProperty target="{canvas1}" name="height" value="660"/>
      <mx:RemoveChild target="{panel3}"/>
      <mx:AddChild relativeTo="{canvas1}" position="lastChild" target="{panel3}"/>
      </mx:State>
      <mx:State name="gift">
      <mx:SetProperty target="{panel1}" name="height" value="766"/>
      <mx:SetProperty target="{panel2}" name="y" value="423"/>
      <mx:SetProperty target="{panel3}" name="y" value="334"/>
      <mx:AddChild relativeTo="{canvas1}" position="lastChild">
      <mx:Panel y="126" height="200" layout="absolute" title="UK Alumni Association Gift Membership Dues" width="618" x="10">
      <mx:RadioButtonGroup id="AssociationDues"/>
      <mx:RadioButton x="10" y="10" label="Student/Recent Graduate Annual Single $20.00*" groupName="AssociationDues"/>
      <mx:RadioButton x="10" y="34" label="Regular Annual Single $40.00" groupName="AssociationDues"/>
      <mx:RadioButton x="10" y="58" label="Life Single (One Payment) $700.00" groupName="AssociationDues"/>
      <mx:Text x="10" y="100" text="*Student/recent graduate membership available only to current UK Students and UK graduates who completed their first UK degree within the last five years." width="550"/>
      </mx:Panel>
      </mx:AddChild>
      <mx:SetProperty target="{tabnavigator1}" name="height" value="709"/>
      <mx:SetProperty target="{canvas1}" name="height" value="659"/>
      </mx:State>
        • 1. Re: RadioButtonGroup
          ur_dtrain Level 1
          As long as the two states are mutually exclusive, you should be able to re-use the name. You can also try nesting the second set of buttons in a seperate container so they don't 'live at the same level; then there should be no name conflict. There is also a concern that if you remove/delete something dynamically, you need to remove all references to it as well (any listeners etc.) otherwise garbage collection will not eliminate it.
          • 2. Re: RadioButtonGroup
            rmorgan Level 1
            Forgive me, I am new to flex. How would I make the states mutually exclusive?
            • 3. Re: RadioButtonGroup
              ur_dtrain Level 1
              Only be able to view one of them at a time, and never both simultaneously. As I mentioned, if you create a new mxml file for the buttons, and then add this custom component in your states, you shouldn't have a name conflict.

              1. create a custom component (a canvas based mxml is fine) and build your button group
              2. in your state add the new component with a unique id

              <AddChild>
              <ns1:myButtonGroup id="buttons1">
              </AddChild>
              • 4. Re: RadioButtonGroup
                rmorgan Level 1
                Thanks, the way i I have it set up now is that only one state will be viewable at a time. When the page initially loads, neither are visible until an option is selected and then the appropriate state is turned visible.
                • 5. Re: RadioButtonGroup
                  rmorgan Level 1
                  Thanks for your help, but was wondering if you could go into a little more detail as to what I need to do, I am still having difficulties in getting the desired results. TIA.