That's exactly what I was looking for! Thanks much for the reply and taking the time to put it in well documented code! Very appreciated.
Thanks again for your help, if you don't mind me asking a couple of more questions...
- With a scrollable Spark List, if a selected item is partially in view, is there a method to get just the visible height of the itemRenderer?
- Also, on my custom paged List component, with a custom itemRenderer and useVirtualLayout = true, after the list data is retrieved a resultHandler is called, in this I then call your getRendererCoordinates function. I also call getRendererCoordinates() in a listChangeHandler.
After the resultHandler calls getRendererCoordinates, even though the dataGroup is showing the proper number of elements, and I set the list.selectedIndex to 0, the renderer variable created in;
var renderer:IVisualElement = list.dataGroup.getElementAt(list.selectedIndex);
the renderer var returns null on the initial display called from the resultHandler, but ... it works perfect on on the listChangeHandler and subsequent page displays. So it seems the renderer is not finished being drawn when getRendererCoordinates is being called from the resultHandler, but subsequent page displays work probably because the renderer has already been drawn. I've tried callLater(getRendererCoordinates) but since nothing else is going on it won't trigger. I did not see an event that can be dispatched from IVisualElement after it is completely drawn that I can use to call getRendererCoordinates.
Thanks again for your help and time,
1. If you are using VerticalLayout or HorizontalLayout then you might find the fractionOfElementInView() method useful.
2. It sounds like the resultHandler is getting fired before the renderers are created, which makes sense on the first page. I'm thinking you could override set data in your renderer to dispatch a custom event. That way any time the data is set on the renderer you can call getCoordinates (see attached). You'll notice that this gets set a few times for each item at first and then set every time the location of the renderers changes (for example by a scroll position change). At this point I'm kind of guessing that is what you are looking for, if it isn't let me know.