Displaying the row number or index in a spark List
The ItemRenderer class in Flex 4 has an itemIndex property that was added after beta2. You can use this property within your item renderer to display the row number or index of an item in a spark List.
The following example demonstrates a List with a custom item renderer that uses this itemIndex property. If you look at the commented out code in the item renderer you will also see a way of getting this information using the getItemIndex() method of the dataProvider.
Note: This sample requires Flex SDK 4.0.0.12093 or higher. You can get the latest SDK builds from opensource.adobe.com.
Has Flex 4 solved the issue that sometimes the set data function will get called before the component is instantiated? If not, it seems like using the setter to directly reference the labels could result in NPE errors.
@Amy – The data setter gets called after the renderer is added to the display list and all of the renderer’s children (such as the Label) are created. This should be the same behavior as in halo. Do you have an example of a case where this failed for you in Flex 3?