# Fl.controls.List: bug or user error?

**URL:** <https://forum.kirupa.com/t/fl-controls-list-bug-or-user-error/229413>\
**Category:** Uncategorized\
**Created:** [June 16, 2007, 11:13pm UTC](https://forum.kirupa.com/t/fl-controls-list-bug-or-user-error/229413 "2007-06-16T23:13:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![markkra](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@markkra](https://forum.kirupa.com/u/markkra)\
**Post date:** [June 16, 2007, 11:13pm UTC](https://forum.kirupa.com/t/fl-controls-list-bug-or-user-error/229413/1 "2007-06-16T23:13:39Z")

</div>

Create a new AS 3.0 fla  
Add a List component to the stage - name it “theList”  
In the parameters panel, add 4 (or more) items.  
Paste the code below in the actions panel:

```auto

import fl.controls.List;
import flash.events.Event;
import fl.accessibility.ListAccImpl;
ListAccImpl.enableAccessibility();
 
// I expected this line 
theList.selectedItem = theList.getItemAt(2);
// or this line, to set the internal index to 2
theList.selectedIndex = 2;
 
theList.setFocus();
theList.addEventListener(Event.CHANGE, onListChange);
function onListChange(e:Event)
{
    trace("You have clicked: " + theList.selectedItem.label + " in row " + theList.selectedIndex);
}
stop();

```

Run it.

The 3rd item (index 2) appears selected in the UI - all seems well.  
Press the down arrow to go to the 4th item in the list. Oops, what happened?

Expect:  
4th item (index 3) is selected.

Actual:  
1st item (index 0) is selected.

Internally, it seems, the object thinks it’s index is still -1 when the Keyboard event arrives.

So, how do you make sure that not only the UI looks correct, but internally, the component remembers it’s selected index?

thanks,  
Mark
