Flex selectComboBox(), mkII
At the suggestion of a coworker, I've made a tiny change to my selectComboBox() function. The purpose of this function is to automatically select something in a ComboBox, such as if you're editing a form. But what if the function ends up doing nothing because no matches were found? Now it'll return false in that case. Also I properly capitalized it.
if( value == null )
return;
for( var i:int=0; i<cb.dataProvider.length; i++ ){
if( value == String(cb.dataProvider[i][column]) ){
cb.selectedIndex = i;
return true;
}
}
return false;
}
Usage:
It will search the dataprovider of cbType, looking at the "type" field, and select the item if it matches the third value passed in. Now to use the returned value...
if( !isMatched ){
/*do some code... add this value to the dataprovider? error message?*/
}
Or hey, get real fancy...
/*do some code... add this value to the dataprovider? error message?*/
}

