In ActionScript 3.0, DataProvider.getItemIndex() method is not working properly. It mostly returns -1, as an indicator of 'Item not found' in the DataProvider.
Following code illustrates the problem ::
import fl.controls.ComboBox;
import fl.data.DataProvider;
var cb:ComboBox = new ComboBox();
this.addChild(cb);
var dp:DataProvider = new DataProvider();
dp.addItem({label:"Ashvin Savani"});
dp.addItem({label:"Naresh Khokhaneshiya"});
dp.addItem({label:"Jignesh Dodiya"});
dp.addItem({label:"Alpesh Vaghasiya"});
cb.dataProvider = dp;
//get index of item 'Naresh Khokhaneshiya'
var index:int = dp.getItemIndex({label:"Naresh Khokhaneshiya"});
//following line outputs :: index : -1, which is totally wrong.
trace("index : " + index);
//set the item selected. Obviously it will give runtime error.
cb.selectedIndex = index;
Naresh Khokhaneshiya
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment