1 Reply Latest reply on Mar 2, 2012 1:38 PM by dazaweb

    Populate comboBox with javascript function

    dazaweb

      Hello, I am very new to Flex my issue is I have a javascript function that contains an array that I want to use to populate a combo box.

       

      javascript:

      //Lab Drop-down menu
      var labSets = Folder(app.path + '/Presets/Template Hub/');
      var labSets = labSets.getFiles(); // this gets all file and folders
      
      
      //Create Array containing Lab names from folder names
      function getLabSets() {
      var labs = [];
      for (i=0; i<labSets.length; i++) {
          if(labSets[i] instanceof Folder ) {
              var v = decodeURI (labSets[i].name); //decodeURI deals with spaces and other chars in folder name
              return v;
              }
          }
      }
      
      

       

      This is all I have come up with in Flex so far, a bit lost.....any explanations and examples would be very educational..

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

                                              layout="absolute"

                                              width="339"

                                              height="815"

                                              minWidth="339"

                                              minHeight="815"

                                              verticalScrollPolicy="off" horizontalScrollPolicy="off"

                                              >

        <mx:Script>

                          <![CDATA[

                                    import com.adobe.csxs.core.CSXSInterface;

                                    import com.adobe.csxs.types.*;

                                    import com.adobe.csxs.events.*;

       

        //Data provider for combobox

                                    cbb_labList.dataProvider = getLabSets;

                          ]]>

        </mx:Script>

                <mx:Button x="9" y="76" label="Daryl's Button"/>

        <mx:ComboBox id="cbb_labList" x="9" y="105"></mx:ComboBox>

       

      </mx:Application>

        • 1. Re: Populate comboBox with javascript function
          dazaweb Level 1

          Here is my latest update to FLEX: Still having issues with pulling in the data.....

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
                                                  layout="absolute"
                                                  width="339"
                                                  height="815"
                                                  minWidth="339" 
                                                  minHeight="815"
                                                  verticalScrollPolicy="off" horizontalScrollPolicy="off"
                                                  >
            <mx:Script>
                              <![CDATA[
                                        import com.adobe.csxs.core.CSXSInterface;
                                        import com.adobe.csxs.events.StateChangeEvent;
                                        import com.adobe.csxs.types.SyncRequestResult;
                                        import com.adobe.csxs.types.WindowGeometry;
                                        import mx.collections.ArrayCollection;
            
            //Data provider for combobox
                                        public function dataList_cbblabList (labId:String):void {
            
                                                  var labSet:SyncRequestResult = CSXSInterface.instance.evalScript("getLabSets", labID);
            
                                                  cbb_labList = new ComboBox
                                                  cbb_labList.id = "cbblabList";
                                                  cbb_labList.dataProvider = getLabSets;
                                        }
                              ]]>
            </mx:Script>
                    <mx:Button x="9" y="76" label="Daryl's Button"/>
            <mx:ComboBox id="cbblabList" x="9" y="105"></mx:ComboBox>
            
          </mx:Application>