1 Reply Latest reply on Mar 12, 2008 8:22 AM by 0degreesK

    ComboBox [type Function] XML problem

    0degreesK
      What I'm trying to accomplish is populating a ComboBox component's labels and data using an Array that's created from an XML data source. I know that I can populate the ComboBox in ActionScript using this:
      ------------------------------------------------------------------------
      comboBox.labels = ["itemA",'itemB","itemC"];
      -OR-
      var cbArray:Array = ["itemA",'itemB","itemC"];
      comboBox.labels = cbArray;
      ------------------------------------------------------------------------

      However, I'm running into problems when the Array is created from my XML datasource, like this:
      ------------------------------------------------------------------------
      for (var g:Number = 0; g < aChildren.length; g++) {
      var aItem:String = aChildren[g].firstChild.firstChild;
      cbArray.push(aItem);
      };

      comboBox.labels = cbArray;
      trace(cbArray);
      ------------------------------------------------------------------------

      I've left all of the XML details (load, onload, etc.) because I don't think that the problem is there. In my example, when I test the movie, the trace(); function displays the correct info, but the comboBox component is populated only with an identical number of instances:
      [type Function],[type Function],[type Function],[type Function],[type Function]...

      I couldn't find a thread anywhere with my particular problem. Any ideas?
        • 1. Re: ComboBox [type Function] XML problem
          0degreesK Level 1
          I'm answering my own question. Hopefully someone will still benefit from it being here. Someone I work with is a JavaScript guru type and he worked through this with me. For some reason, the aItem variable isn't being perceived as a string. So, the solution I found was to alter the code here:
          ----------------------------------------------------------------------
          ...
          var aItem:String = aChildren[g].firstChild.firstChild.toString();
          ...
          ----------------------------------------------------------------------

          This fixed my problem.