I had been trying to figure out how to make an automatic selection of an item in a List component and I figured it out after messing with it for some time. This script makes the desired item in the list selected as soon as it loads. If listeners are associated with the component instance, 'itemRollOver' and 'change' events are also triggered if available.
I thought someone else might need it so here it is.
ActionScript Code:
myList.doLater(this, "selectInitialItem");
// change 'myList' above to the List instance of yours
var initIndex:Number = 0;
// initial index of the List instance to be activated
function selectInitialItem() {
var list:mx.controls.List = myList;
// change 'myList' above to the List instance of yours
var s:Number = initIndex;
if (initIndex == undefined || initIndex < 0) s = 0;
else if (initIndex > list.dataProvider.length-1) {
s = list.dataProvider.length - 1;
}
list["content_mc"]["listRow"+(10+s)].bG_mc.onRollOver();
list["content_mc"]["listRow"+(10+s)].bG_mc.onPress();
list["content_mc"]["listRow"+(10+s)].bG_mc.onRelease();
list.selected = {};
list.selected[s.toString()] = s;
list.onMouseUp();
}