2 Replies Latest reply on Jul 12, 2007 9:02 AM by Newsgroup_User

    Array Collection "get item at" question

    Handycam Level 1
      I have an app with an array collection, here's the fist 2 items:

      [Bindable]
      private var ingredientList:ArrayCollection = new ArrayCollection([
      {label:"Celery, chopped", min:1, max:2,def:1, units:"cups"},
      {label:"Onions, chopped", min:2, max:3, def:1, units:"cups"}]);

      I'm referencing these items in form controls, as in:

      <mx:FormItem>
      <mx:HBox>
      <mx:CheckBox id="c0" width="{colW}" label="{ingredientList[0].label}" change="enableStepper(q0,c0)" selected="false" />
      <mx:NumericStepper id="q0" width="{nsW}" minimum="{ingredientList[0].min}" maximum="{ingredientList[0].max}" stepSize=".5" enabled="false"/>
      <mx:Label text="{ingredientList[0].units}"/>
      </mx:HBox>
      </mx:FormItem>

      Now, this seems to work, but the compiler "complains" (yellow icon) about me accessing the array members with bracket notation, saying I should "use ArrayCollecyion.getItemAt()".

      Why, and how does that work, exactly? How would I re-write my code to use the preferred method?

      Thanks.
        • 1. Re: Array Collection &quot;get item at&quot; question
          Level 7
          I got the same problem. I got it to work with
          ingredientList.getItemAt(0).max
          If you need to pass as string use:
          ingredientList.getItemAt(0).max .toString()

          I hope this help
          JFB


          "Handycam" <webforumsuser@macromedia.com> wrote in message
          news:f75ig6$3sm$1@forums.macromedia.com...
          >I have an app with an array collection, here's the fist 2 items:
          >
          > [Bindable]
          > private var ingredientList:ArrayCollection = new ArrayCollection([
          > {label:"Celery, chopped", min:1, max:2,def:1, units:"cups"},
          > {label:"Onions, chopped", min:2, max:3, def:1, units:"cups"}]);
          >
          > I'm referencing these items in form controls, as in:
          >
          > <mx:FormItem>
          > <mx:HBox>
          > <mx:CheckBox id="c0" width="{colW}" label="{ingredientList[0].label}"
          > change="enableStepper(q0,c0)" selected="false" />
          > <mx:NumericStepper id="q0" width="{nsW}" minimum="{ingredientList[0].min}"
          > maximum="{ingredientList[0].max}" stepSize=".5" enabled="false"/>
          > <mx:Label text="{ingredientList[0].units}"/>
          > </mx:HBox>
          > </mx:FormItem>
          >
          > Now, this seems to work, but the compiler "complains" (yellow icon) about
          > me
          > accessing the array members with bracket notation, saying I should "use
          > ArrayCollecyion.getItemAt()".
          >
          > Why, and how does that work, exactly? How would I re-write my code to use
          > the
          > preferred method?
          >
          > Thanks.
          >


          • 2. Re: Array Collection &quot;get item at&quot; question
            unix0405 Level 1
            just need to replace [0] with getItemAt(0) and leave everything else the same.