3 Replies Latest reply on Nov 3, 2008 9:25 AM by spacehog

    Array Collection issue

    spacehog
      I have a combobox that I would like to be populated with values from an array that is chosen from a switch statement. The problem I am having is that the only thing I can get to display name of the function for the switch. The comboBox in question is in the state called "step2" and I want it to be populated with one of the ArrayCollections in the function getTool() based on the selection from the first comboBox displayed cbxServCen.

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#3F3D3D, #3F3D3D]">
      <mx:states>
      <mx:State name="step2">
      <mx:AddChild relativeTo="{frmChartConfig}" position="lastChild">
      <mx:FormItem label="Tool">
      <mx:ComboBox id="cbxTool" dataProvider="getTool(cbxServCen.label)" />
      </mx:FormItem>
      </mx:AddChild>
      </mx:State>
      </mx:states>
      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;

      public var toolList:ArrayCollection;
      [Bindable]
      public var servCen:ArrayCollection = new ArrayCollection(
      [{label:"ECAE", data:1},{label:"MCAE", data:2}, {label:"SSCAE", data:3}]);

      public function getTool(tool:String):ArrayCollection{
      switch(tool){
      case "ECAE":
      var toolList:ArrayCollection = new ArrayCollection(
      [{label:"Actel", data:701},{label:"Agilent", data:702},{label:"Ansoft", data:703},]);
      break;
      case "MCAE":
      var toolList:ArrayCollection = new ArrayCollection(
      [{label:"Femap", data:501},{label:"NX (Adv. Des.)", data:502},{label:"NX (Mfg)", data:503},]);
      break;
      case "SSCAE":
      var toolList:ArrayCollection = new ArrayCollection(
      [{label:"STK", data:101},{label:"Windriver", data:102},{label:"Telelogic", data:03},]);
      break;
      }
      return toolList;
      }

      ]]>
      </mx:Script>

      <mx:Text text="CAE Usage Center" textAlign="center" fontSize="26" fontWeight="bold" fontFamily="Georgia" color="#FDFEFE" width="1197"/>
      <mx:Form x="315" y="292" width="485" backgroundColor="#032697" backgroundAlpha="0.18" height="152" id="frmChartConfig" color="#FCFEFE" fontSize="17" fontWeight="bold">
      <mx:Label text="Choose a Service Center"/>
      <mx:FormItem>
      <mx:ComboBox id="cbxServCen" dataProvider="{servCen}" enabled="true" editable="false" color="#0E0D0D" fontSize="12" change="currentState='step2'"/>
      </mx:FormItem>
      </mx:Form>

      </mx:Application>


        • 1. Re: Array Collection issue
          Level 7

          "spacehog" <webforumsuser@macromedia.com> wrote in message
          news:gen7aj$gve$1@forums.macromedia.com...
          >I have a combobox that I would like to be populated with values from an
          >array
          > that is chosen from a switch statement. The problem I am having is that
          > the
          > only thing I can get to display name of the function for the switch. The
          > comboBox in question is in the state called "step2" and I want it to be
          > populated with one of the ArrayCollections in the function getTool() based
          > on
          > the selection from the first comboBox displayed cbxServCen.
          >
          > <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
          > layout="absolute"
          > backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#3F3D3D,
          > #3F3D3D]">
          > <mx:states>
          > <mx:State name="step2">
          > <mx:AddChild relativeTo="{frmChartConfig}" position="lastChild">
          > <mx:FormItem label="Tool">
          > <mx:ComboBox id="cbxTool" dataProvider="getTool(cbxServCen.label)" />
          > </mx:FormItem>
          > </mx:AddChild>
          > </mx:State>
          > </mx:states>
          > <mx:Script>
          > <![CDATA[
          > import mx.collections.ArrayCollection;
          >
          > public var toolList:ArrayCollection;
          > [Bindable]
          > public var servCen:ArrayCollection = new ArrayCollection(
          > [{label:"ECAE", data:1},{label:"MCAE", data:2}, {label:"SSCAE",
          > data:3}]);
          >
          > public function getTool(tool:String):ArrayCollection{
          > switch(tool){
          > case "ECAE":
          > var toolList:ArrayCollection = new ArrayCollection(
          > [{label:"Actel", data:701},{label:"Agilent", data:702},{label:"Ansoft",
          > data:703},]);
          > break;
          > case "MCAE":
          > var toolList:ArrayCollection = new ArrayCollection(
          > [{label:"Femap", data:501},{label:"NX (Adv. Des.)", data:502},{label:"NX
          > (Mfg)", data:503},]);
          > break;
          > case "SSCAE":
          > var toolList:ArrayCollection = new ArrayCollection(
          > [{label:"STK", data:101},{label:"Windriver",
          > data:102},{label:"Telelogic", data:03},]);
          > break;
          > }
          > return toolList;
          > }
          >
          > ]]>
          > </mx:Script>
          >
          > <mx:Text text="CAE Usage Center" textAlign="center" fontSize="26"
          > fontWeight="bold" fontFamily="Georgia" color="#FDFEFE" width="1197"/>
          > <mx:Form x="315" y="292" width="485" backgroundColor="#032697"
          > backgroundAlpha="0.18" height="152" id="frmChartConfig" color="#FCFEFE"
          > fontSize="17" fontWeight="bold">
          > <mx:Label text="Choose a Service Center"/>
          > <mx:FormItem>
          > <mx:ComboBox id="cbxServCen" dataProvider="{servCen}" enabled="true"
          > editable="false" color="#0E0D0D" fontSize="12"
          > change="currentState='step2'"/>
          > </mx:FormItem>
          > </mx:Form>
          >
          > </mx:Application>
          >
          >
          >
          >


          • 2. Re: Array Collection issue
            Level 7

            "spacehog" <webforumsuser@macromedia.com> wrote in message
            news:gen7aj$gve$1@forums.macromedia.com...
            >I have a combobox that I would like to be populated with values from an
            >array
            > that is chosen from a switch statement. The problem I am having is that
            > the
            > only thing I can get to display name of the function for the switch. The
            > comboBox in question is in the state called "step2" and I want it to be
            > populated with one of the ArrayCollections in the function getTool() based
            > on
            > the selection from the first comboBox displayed cbxServCen.
            >
            > <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
            > layout="absolute"
            > backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#3F3D3D,
            > #3F3D3D]">
            > <mx:states>
            > <mx:State name="step2">
            > <mx:AddChild relativeTo="{frmChartConfig}" position="lastChild">
            > <mx:FormItem label="Tool">
            > <mx:ComboBox id="cbxTool" dataProvider="getTool(cbxServCen.label)" />

            Oops. Hit send too soon. cbxServCen doesn't have a label. You probably
            want to look at its value, anyway.


            • 3. Re: Array Collection issue
              spacehog Level 1
              Thanks Amy. Your reply got me thinking and I realized I had forgotten what object I was using. I needed to pass:

              dataProvider= "{getTool(cbxServCen.selectedItem.data)}"