1 Reply Latest reply on Jun 16, 2009 11:41 AM by Peter deHaan

    Getting a list's selected index

    Handycam Level 1

      I have a data list:


      <s:List id="stepList" width="100%" height="100%" contentBackgroundColor="0xffffff" selectionChanged="choiceMade(event)" />


      and I have the handler:


      private function choiceMade(e:IndexChangedEvent):void {




      The problem is the trace statement always returns 2 numbers: the old index and the one it just changed to.  I only want to keep what is currently active (i.e. what the user chose).

        • 1. Re: Getting a list's selected index
          Peter deHaan Level 4



          I can't reproduce that issue using Flex SDK and the following test case:

          <?xml version='1.0' encoding='UTF-8'?>
          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                      import mx.events.IndexChangedEvent;
                      private function choiceMade(e:IndexChangedEvent):void {
                          debug.text = "ActionScript: " + e.currentTarget.selectedIndex.toString();
              <s:Panel width="400" height="300" initialize="sdkVer.text = mx_internal::VERSION;">
                      <s:VerticalLayout />
                  <s:List id="stepList" width="100%" height="100%" contentBackgroundColor="0xffffff" selectionChanged="choiceMade(event)">
                  <s:SimpleText id="debug" />
                  <s:SimpleText text="Data binding: {stepList.selectedIndex}" />
                  <mx:HRule width="100%" />
                  <s:SimpleText id="sdkVer" />


          Do you still see the issue if you try a newer build of the Flex SDK from http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4 ?