1 Reply Latest reply on May 25, 2007 4:33 PM by peterent

    Dynamic Combo Boxes

      public var arySizes:Array = new Array( {label:'Size'},{label:'1'},{label:'2'} );

      currently that is what I use for a dataProvider in a combobox.

      How would I bring in XML for a dynamic combo box?

      In other words, if I wanted to create that array in actionscript 1 record at a time, how would I do it?

      arySizes[arySizes.length] = 'Size';

      or something like that?
        • 1. Re: Dynamic Combo Boxes
          peterent Level 2
          You want to create this as an XML structure, one element at time. OK:

          var sizes:XML = <sizes />; // start off with an empty structure
          for(var i:int=0; i < 12; i++) { b// some number of sizes
          var item:XML = <size />; item.@label = String(i);

          When this loop is done you'll have something like this:
          <sizes><size label="0" /><size label="1" /><size label="2" /> ... </sizes>

          For your ComboBox, you then do:
          <mx:ComboBox dataProvider="{sizes.size}" labelField="@label" />

          The dataProvider is set to sizes.size which creates an XMLList. Now, you could actually just use the loop to build the XMLList and not an XML structure, so you can alter it if you need to.