3 Replies Latest reply on Nov 4, 2006 7:04 PM by leotemp

    Change a STATE depending in a radio button

    Saintcorp
      HI everyone.

      I need to do this little thing, but is have been a real pain in the neck.

      I have a radio buttons and depending in wich selection is pressed, the state the user will go.

      Example..

      --------------------------------------
      Select your favourite Tv Show:

      ( ) 4400
      (o) Lost
      ( ) Prison Break

      Submit
      ---------------------------------------

      When the user presses submit, he will be sent to LOST state.
      I mean, currentState='lost'
      Or send him to state "prison" if he choose Prison Break.
      Like currentState='userselection' or something....

      Please someone help doing this!! Please!!

      Thanks!
        • 1. Change a STATE depending in a radio button
          leotemp Level 1
          You need to trigger a function for the "change" event and in the funciton set the state, A simple example:
          <mx:Script>
          <![CDATA[
          private function changeStateRadio():void {
          currentState= radiogroup1.selectedValue.toString();
          }
          ]]>
          </mx:Script>

          <mx:RadioButtonGroup id="radiogroup1"/>
          <mx:RadioButton x="211.0" y="479.0" label="LOST" groupName="radiogroup1" click="{changeStateRadio()}"/>
          <mx:RadioButton x="211.0" y="503.0" label="Prison Rape" groupName="radiogroup1" click="{changeStateRadio()}"/>
          • 2. Re: Change a STATE depending in a radio button
            Saintcorp Level 1
            I appreciate your colaboration, but I think that your code is the same that doing this:

            <mx:RadioButtonGroup id="radiogroup1"/>
            <mx:RadioButton x="211.0" y="479.0" label="LOST" groupName="radiogroup1" click="currentState='lost'"/>
            <mx:RadioButton x="211.0" y="503.0" label="Prison Rape" groupName="radiogroup1" click="currentState='prisonrape'"/>


            I need to know wich button marked the user and based on that take him to its respective State. But not changing state right after pressing the radio button, just after pressing the 'Submit' button.

            Thanks a lot and please help me with this... is the last thing in my project!!
            • 3. Re: Change a STATE depending in a radio button
              leotemp Level 1
              well it would be the same thing i posted just triggered by a button or something like that. You can call radiogroup1.selectedValue.toString(); at any time from any function and if there is a selection you will get the string from the radio button.

              <mx:Script>
              <![CDATA[
              private function changeStateRadio():void {
              currentState= radiogroup1.selectedValue.toString();
              }
              ]]>
              </mx:Script>

              <mx:RadioButtonGroup id="radiogroup1"/>
              <mx:RadioButton x="211.0" y="479.0" label="LOST" groupName="radiogroup1" click="{changeStateRadio()}"/>
              <mx:RadioButton x="211.0" y="503.0" label="Prison Rape" groupName="radiogroup1"/>
              <mx:Button click="{changeStateRadio()}" label="Vote"/>