PDA

View Full Version : Problem with selectedIndex and list component


darkee999
04-28-2008, 06:57 PM
I have a list on the stage populated with a list of items that I insert one by one. I would like to move the items up/down using some buttons.

This is the code that should move an item:
on (release) {
c = this._parent.listaPoze.selectedIndex;
a = this._parent.listaPoze.getItemAt(c-1);
b = this._parent.listaPoze.getItemAt(c);

this._parent.listaPoze.replaceItemAt(c-1,b);
this._parent.listaPoze.replaceItemAt(c--,a);
this._parent.listaPoze.selectedIndex = c;
this._parent.listaPoze.dispatchEvent({type:"change", target:this._parent.listaPoze});
}

It should move the selected object up and reselect the item that is now a row higher. Actually it selects the old and the new position of the object. Could you please help me! Thank you very much!