2 Replies Latest reply on Aug 10, 2009 7:35 AM by domflexdom

    Strings to displayObject

    domflexdom

      Hello,

       

      I need to populate combo box with an ArrayCollection that contains mutiple values.

       

      I have done a loop in wich every value of type String can be attributed.

       

      Though, to populate the combo box i can only use the method addChild

       

      myComboBox.addChild(child:DisplayObject):DisplayObject.

       

      how can I pass a string to some DisplayObject.

       

      OR , is there another way to populate a combo box using Strings ?

       

      remember that i'm in the  <mx:Script><![CDATA[ ]]><!/mx:Script>

      tag, which means that i can't simply use the <mx:array> <mx:String>value</mx:String></mx:array> tags

       

      any ideas ?

       

      thanks

       

      dom

        • 1. Re: Strings to displayObject
          Gregory Lafrance Level 6

          You never use addChild to populate a ComboBox:

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            creationComplete="init();">
            <mx:Script>
              <![CDATA[
               import mx.controls.ComboBox;
                import mx.collections.ArrayCollection;
               
                [Bindable] private var ac:ArrayCollection = new ArrayCollection([
                  "one", "two", "three", "four"
                ]);
               
                private function init():void{
                  var cbx:ComboBox = new ComboBox();
                  cbx.dataProvider = ac;
                  hb.addChild(cbx);
                }     
              ]]>
            </mx:Script>
            <mx:HBox id="hb">
              <mx:ComboBox dataProvider="{ac}"/>  
            </mx:HBox>
          </mx:Application>

          If this post answered your question or helped, please mark it as such.

          • 2. Re: Strings to displayObject
            domflexdom Level 1

            Actually, i fixed my problem by filling an array from a determined field from my arrayCollection. And i used that new array as a dataprovider for my dropBoxes.

             

            The array is created each time the program request a newer version of the database's query.