1 Reply Latest reply on Apr 16, 2007 9:32 AM by parallaxed

    ArrayCollection As A dataProvider

    AwesomeDigital3 Level 1
      I am loading an external XML file into an ArrayCollection, then Binding a comboBox to that

      <BooksOfTheBible>
      <BookNumber>1</BookNumber>
      <Abbreviation>Gen.</Abbreviation>
      <BookName>Genesis</BookName>
      </BooksOfTheBible>
      <BooksOfTheBible>
      <BookNumber>2</BookNumber>
      <Abbreviation>Ex.</Abbreviation>
      <BookName>Exodus</BookName>
      </BooksOfTheBible>
      <BooksOfTheBible>
      <BookNumber>3</BookNumber>
      <Abbreviation>Lev.</Abbreviation>
      <BookName>Leviticus</BookName>
      </BooksOfTheBible>
      <BooksOfTheBible>
      ...


      <mx:ComboBox rowCount="30" id="bookOfTheBible" dataProvider="{bibleBooks}" labelField="BookName" />

      The combo box fills fine with the BookName, but when an item is selected, I would like to retreive the book number from the ArrayCollection.

      Is that possible? I have been looking through the help but I have not yet found a way.

      Thanks
      Mathias

        • 1. Re: ArrayCollection As A dataProvider
          parallaxed
          ArrayCollections created from XML will be collections of Object instances. Object is a dynamic type, so the names of your elements will be added (at runtime) to the Object instance.

          You can access them like any other object property... i.e.

          <mx:Label text="BookNumber: {bookOfTheBible.selectedItem.BookNumber}" />
          - or -
          <mx:Label text="BookNumber: {bookOfTheBible.selectedItem.['BookNumber']" />