In Flex I can create an ItemRenderer to represent each item in the Lists DataProvider but how do I access the instance of the ItemRenderer via the DataProviders Object? Something like myList.getItemRenderer(dp.getItemAt(10));
views:
24answers:
1
A:
public function getItemRenderer(list:List, item:Object):ItemRenderer
{
var dataGroup:DataGroup = list.dataGroup;
var n:int = dataGroup.numElements;
for (var i:int = 0; i < n; i++)
{
var renderer:ItemRenderer = dataGroup.getElementAt(i) as ItemRenderer;
if (renderer && renderer.data == item)
return renderer;
}
}
Maxim Kachurovskiy
2010-10-27 15:59:23