5 Replies Latest reply on Feb 19, 2009 3:35 PM by Gregory Lafrance

    ComboBox and States

      I need to know how can I change between states with a ComboBox?

      I know how to with a simple LinkButton but I have around 7 options I need people to choose from so I'd rather have a ComboBox to save the interface from cluttering it up with a bunch of buttons.

      I tried with the same concept but to no avail:
        • 1. Re: ComboBox and States
          atta707 Level 2
          add the 'change' event listener and when the listener function fires you'll check the selected index of the combo box to change the state:

          the code below may no compile:

          switch(combo.selectedIndex) {
          case 0: this.currentState = ''; break;
          case 1: this.currentState = 'state1'; break;
          • 2. Re: ComboBox and States
            5281s1 Level 1
            I'm not sure what that means. It can't be that different from a LinkButton?
            • 3. Re: ComboBox and States
              Gregory Lafrance Level 6
              Assign a listener for the ComboBox "change" event.

              In the change listener, simply use the ComboBox "selectedIndex" value to determine the state you switch to. You don't have to use selectedIndex. You could use the ComboBox selectedLabel or the data value as well.
              • 4. Re: ComboBox and States
                5281s1 Level 1
                I added this script to the app:

                var currentstate:Object = new Object();

                Then this for the combobox:

                <mx:ComboBox x="10" y="55" id="combobox1">
                <mx:Object label="Choose" data="0"/>
                <mx:Object selectedIndex="currentstate='I'" label="I" data="1"/>
                <mx:Object label="II" data="2"/>
                <mx:Object label="III" data="3"/>

                Does it not work because the combobox id isn't being called?
                • 5. Re: ComboBox and States
                  Gregory Lafrance Level 6
                  You need to search FB help for how to add event listeners in MXML, in this case for the ComboBox change handler.