I'm using Flex 4.11 with Air 4.0 to create a mobile app. I have a spark list with a custom mxml itemRenderer. Only 4 instances will be visible in the list. The dataprovider is initially empty.
When I assign the array collection with an array of 147 items, I get 147 traces on dataChange event and on the render event. I traced out the value of 'this' and I get 147 unique objects. I was under the impression that only 4 instances of the itemRenderer will be created and get reused as I scroll through the list. What have I overlooked? The list is defined as:- <s:List id="lImages" dataProvider="{imageList}" width="100%" height="100%" allowMultipleSelection="true" change="lImagesChange(event)" itemRenderer="PhotoThumbNail" doubleClickEnabled="true" doubleClick="showImage(event)"> <s:layout> <s:TileLayout/> </s:layout> </s:List> and the itemRenderer is defined as:- <?xml version="1.0"?> <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" dataChange="onDataChange(event)" render="onRender(event)" width="150" height="175" > <s:layout> <s:VerticalLayout/> </s:layout> <fx:Script><![CDATA[ import DateUtils; import mx.events.FlexEvent; private function onDataChange(event:FlexEvent):void { trace(DateUtils.currentTime() + "PhotoThumbNail.onDataChange: dataChange event, index=" + itemIndex + ", this="+this); } private function onRender(event:Event):void { trace(DateUtils.currentTime() + "PhotoThumbNail.onRender; render event, index=" + itemIndex + ", this="+this); } ]]></fx:Script> <s:BitmapImage source="{data.image}" width="150" height="150"/> <s:Label text="{data.timestamp}" width="150"/> </s:ItemRenderer> -- Chris -- Chris Velevitch Manager - Adobe Platform Users Group, Sydney m: 0415 469 095 www.apugs.org.au Adobe Platform Users Group, Sydney Topic: TBD Date: Monday, 28th February Details and RSVP on http://www.meetup.com/Sydney-Adobe-Platform-User-Group