title: AS3: How to access data in XMLListCollection using ActionScript3?
body: <p>I'm using an XMLListCollection for a spark ComboBox, inspired by this link</p>
  
  <p><a href="http://blog.shortfusion.com/index.cfm/2009/4/15/FlexAS3-Custom-ComboBox-for-Countries-with-XML" rel="nofollow noreferrer">http://blog.shortfusion.com/index.cfm/2009/4/15/FlexAS3-Custom-ComboBox-for-Countries-with-XML</a></p>
  
  <p>The XMLListCollection is defined here:</p>
  
  <pre><code>public class ComboBox_Country extends ComboBox {
  
      private var Country:XML=new XML(
          &lt;countries&gt;
           &lt;country code="US" iso="840" label="United States" /&gt;
           &lt;country code="CA" iso="124" label="Canada" /&gt;
           &lt;country code="GB" iso="826" label="United Kingdom" /&gt;
                       ....
           &lt;country code="ZM" iso="894" label="Zambia" /&gt;
           &lt;country code="ZW" iso="716" label="Zimbabwe" /&gt;
          &lt;/countries&gt;);
  
      public function ComboBox_Country() {
          dataProvider = new XMLListCollection(Country.children());
          labelField = '@label';
      }
  </code></pre>
  
  <p>and called in mxml as:</p>
  
  <pre><code>&lt;mycomp:ComboBox_Country id="countryComboBox" width="100%"/&gt;
  </code></pre>
  
  <p>When the user makes a selection, I can get the index from: <code>countryComboBox.selectedIndex</code>. But, I need the string for the country, and I'm not sure how to extract that from an XMLListCollection. When I look in the debugger I see:</p>
  
  <p><img src="https://i.stack.imgur.com/UzWlC.png" alt="enter image description here"></p>
  
  <p>Let's say the user selected index 2 (e.g. United Kingdom). What would I need to type into the debugger to return <code>United Kingdom</code>? I've tried things like:</p>
  
  <pre><code>countryComboBox.Country.getItemAt(2)
  countryComboBox.Country.getItemAt(2).label
  countryComboBox.Country[2]
  countryComboBox.Country.label.getItemAt(2)
  etc...
  </code></pre>
  
  <p>to no avail. </p>