6 Replies Latest reply on Apr 14, 2007 6:30 AM by Newsgroup_User

    Combo boxes???

    paulpsd7 Level 1
      I have a Flash piece with several combo boxes in it.

      Let's say the instance name of one of the combo boxes is "age".

      I want to do a few things:
      1) See what the value of the combo box is.
      2) Set the value of the combo box
      3) Set the font that appears in all combo boxes throughout the piece. If there's a global command for this, that would be ideal.

      Thanks in advance for any help.
        • 1. Re: Combo boxes???
          Level 7
          You might try looking in the Help, there's a whole method table for the
          ComboBox component.

          trace(instanceName.selectedItem.label);
          trace(instanceName.selectedItem.data);
          instanceName.selectedIndex = x;


          --
          Dave -
          Head Developer
          www.blurredistinction.com
          Adobe Community Expert
          http://www.adobe.com/communities/experts/


          • 2. Re: Combo boxes???
            paulpsd7 Level 1
            quote:

            You might try looking in the Help, there's a whole method table for the
            ComboBox component.


            That's exactly what I did. The Help file gives some truly bad code that doesn't work, which is why I came here. So you know, the Help file provides this code for getting the value of a combo box:

            ageSelected = age.getItemAt[x];

            That won't work.

            It also says this is how you set the style of a combo box:

            age.setStyle("color", 0x666549);
            age.setStyle("fontSize",16);
            age.setStyle("fontFamily" , "Verdana");
            age.setStyle("fontWeight" , bold);

            That doesn't work either.

            Basically, the help file is often more of a hindrance than a help, but of course I always try that first.

            Anyhow, thanks for letting me know how I can get the value of a combo box. Tell me, is it also possible to set the value of a combo box? And is there anything I can do to set the font?
            • 3. Re: Combo boxes???
              kglad Adobe Community Professional & MVP
              just put bold in quotes. the rest of your style should be ok.
              • 4. Re: Combo boxes???
                paulpsd7 Level 1
                That worked! Thanks! (Sometimes, I think it must be a talent to read between the lines of the Online Help file.)

                Okay, next question. Say, I've got a combo box on the stage called "age." When it appears, I need to check the value of another variable, _root.dataStore.age. If a value exists, I want to set the combo box to show the same value. (To confirm, the value is contained in the combo box as static data.)

                How would I do that?
                • 5. Re: Combo boxes???
                  kglad Adobe Community Professional & MVP
                  (and i tried to answer your private message, but you don't accept private messages so i couldn't directly respond.)

                  the answer is yes i do flash actionscripting professionally. you can contact me at kglad@hotmail.com
                  • 6. Re: Combo boxes???
                    Level 7
                    I did say how to set - you set the selectedIndex property of the comboBox.
                    Iterate through the list of items in the box- when the item's label matches
                    what you are testing against, set the selectedIndex... Here's a method I
                    use:

                    function setCombo(comboRef, test:String)
                    {
                    var l = comboRef.length;
                    for (var i = 0; i < l; i++) {
                    if (comboRef.getItemAt(i).label == test) {
                    comboRef.selectedIndex = i;
                    break;
                    }
                    }
                    }

                    --
                    Dave -
                    Head Developer
                    http://www.blurredistinction.com
                    Adobe Community Expert
                    http://www.adobe.com/communities/experts/