6 Replies Latest reply on Jun 24, 2011 1:39 AM by Designscripting

    ComboBox not setting any 'selected' text

    allandt Level 1
      i'm having some trouble with an actionscript-generated ComboBox

      here's my script

      //create object to pass to ComboBox init
      var comboInit:Object = new Object();
      //create array to pass to combobox and set initial state
      var sizes:Array = [{thisSize: "choose one"}];
      //populate array
      for (var i:Number = 0; i < productArray[product].sizes.length; i++) {
      sizes.push ({thisSize:productArray[product].sizes });
      }
      comboInit._y = 450;
      comboInit._x = 500;
      comboInit.dataProvider = sizes;
      comboInit.labelField = "thisSize";
      createClassObject(ComboBox, "variationCombo", 5004, comboInit);

      when the drop down happens, i can see all of the values that were passed to the ComboBox but there's no text on the 'up' state, either before it is used or after a selection is made.

      it is above everything else

      i have tried several ways of passing the data to the ComboBox
      eg
      var combo:ComboBox = createClassObject(ComboBox, "variationCombo", 5004);
      combo._y = 450;
      combo._x = 500;
      combo.labelField = "thisSize";
      combo.dataProvider = sizes;

      but nothing seems to work

      really hope you can help
      a
        • 1. Re: ComboBox not setting any 'selected' text
          allandt Level 1
          i have also tried
          var combo:ComboBox = createClassObject(ComboBox, "variationCombo", 5004);
          combo.addItem("Size");
          for (var i:Number = 0; i < productArray[product].sizes.length; i++) {
          combo.addItem(productArray[product].sizes );
          }
          combo._y = 445;
          combo._x = 530;

          with the same result
          • 2. Re: ComboBox not setting any 'selected' text
            Greg Dove Level 4
            Hint: If you're posting code use the attach Code button. You're missing some code because part of it is interpreted as italic formatting in the forum post.

            I've used the following code with a comboBox in the library and it worked as it should.

            Only thing I can think of (may not be correct) is there is some depth management conflict with your assigned depth of 5004. I think for V2 components you're supposed to use depthmanger class to manage depths. I've never used it so can't advise. But it sounds from what you're described as some sort of depth management problem....I think.
            • 3. Re: ComboBox not setting any 'selected' text
              allandt Level 1
              thanks for the response - i'm still getting the same problem

              to all intents and purposes, the ComboBox is working fine - it retains the selected option and everything - the only problem is that it isn't displaying the selection when 'rolled up'

              so wierd
              • 4. ComboBox not setting any 'selected' text
                allandt Level 1
                gah!!!!!!!!

                it's taken all weekend but i've found out what the problem was

                i add this to my as and the current selection appeared

                // initialize items on stage
                _global.styles.ComboBox.setStyle("fontFamily", "Verdana");
                _global.styles.ComboBox.setStyle("fontSize", 11);

                don't know why really unless the selected item area is constructed with a TextArea (i have the following styles set on the TextArea)

                _global.styles.TextArea.setStyle("backgroundColor", "transparent");
                _global.styles.TextArea.setStyle("borderStyle", "none");
                _global.styles.TextArea.setStyle("embedFonts", true);

                best
                • 5. ComboBox not setting any 'selected' text
                  Greg Dove Level 4
                  Good catch. looks like your embed fonts was set via styles, but your font wasn't set to the embedded font (my guess)
                  Why? -

                  FYI (livedocs excerpt):
                  The TextArea and TextInput components both use the same styles and are often used in the same manner. Thus, by default they share the same class-level style declaration. For example, the following code sets a style on the TextArea declaration but it affects both TextArea and TextInput components.

                  _global.styles.TextArea.setStyle("disabledColor", 0xBBBBFF);


                  By setting it at the combobox level you over-ride the _global style which gets applied to the textinput inside the combobox
                  • 6. Re: ComboBox not setting any 'selected' text
                    Designscripting

                     


                    Hi, Follow this tutorial and use the code below..
                    http://www.designscripting.com/2011/06/as3-combobox-font-embedding-problem-flash-cs5/
                    
                    var arial:Font = new ArialFont();
                    
                    var myFormatBlack:TextFormat = new TextFormat();
                    myFormatBlack.font = arial.fontName;
                    myFormatBlack.size = 18;
                    myFormatBlack.color = 0x000000;
                    
                    myComboBox.textField.setStyle("embedFonts", true);
                    myComboBox.textField.setStyle("textFormat", myFormatBlack);
                    myComboBox.dropdown.setRendererStyle("embedFonts", true);
                    myComboBox.dropdown.setRendererStyle("textFormat", myFormatBlack);
                    myComboBox.setStyle("embedFonts", true);
                    myComboBox.setStyle("textFormat", myFormatBlack);
                    myComboBox.prompt = "Select State";
                    myComboBox.width = 248;
                    myComboBox.height = 25;
                    myComboBox.x = 100
                    myComboBox.y = 100
                    myComboBox.setStyle("textPadding", 1);