apache-flexairflex4actionscript-3

Access itemRenderer in List


How to access List itemRenderer and its properties (Spark - Flex 4)? I want to iterate through list and do something like (note it's pseudo code):

for (var i=0;i<NUMBER_OF_ITEMS_IN_LIST; i++){
  myList.getItemRenderer[i].property
}

Solution

  • What type of processing do you want to perform on the renderers? I suspect a loop like that will not give you what you need.

    Renderers are only created for the elements that you see on the screen. There will not be a renderer for every item in your dataProvider. This is done for performance issue. You should be able to access the List renderers through some property in the API, but it may not be public, or documented. I took a quick look and couldn't tell.

    In the Halo ListBase, there are protected properties named reservedItemRenderers and freeItemRenderers properties. I assume they must be something similar in the Spark List.