2 Replies Latest reply on Sep 14, 2011 6:54 AM by mocodere

    How to customize display in ItemRenderer depending on its index in dataProvider in Flex 4.1?

    mocodere Level 1

      I've been through a lot of forums to get this answer, without luck. I have to admit, I'm pretty 'green' with Flex, and my first language is French, so if I'm not clear, I apologize.


      I would like to use the same ItemRenderer for all the items in a List, but only for the first item (index=0) in the dataProvider I would like to make 1 of the ItemRenderer's child not visible.


      Currently, i have something like this in the ItemRenderer:


      override public function set data(value:Object):void{


           var itemList:List = owner as List;


           var listProvider:ArrayCollection = itemList.dataProvider as ArrayCollection;


           var isFirstItem:Boolean = false;

           if(listProvider.getItemIndex(data) == 0){

                isFirstItem = true;





      And then, if isFirstItem=true, I hide the child that I wanted to hide for the first item in the data provider.


      The problem is that listProvider.getItemIndex(data) == 0 seems to be true not only for the 1st item in the dataProvider. The child that I want to hide gets hidden on other items too (not all of them).


      It seems to be related with the fact that the list has a scroller and therefore not all the items in the List are shown at the same time.


      Does anyone have an idea of how I could do this? Or simple some pointers, I'm really out of solutions here.