Hi, Set the List's variableRowHeight="true" and use something like this in the itemRenderer:
override protected function measure():void { var textLineMetrics:TextLineMetrics = comment.measureText( comment.text ); // should add paddingTop, paddingBottom and verticalGap to this too measuredHeight = textLineMetrics.height + myLinkButton.height; } -TH --- In flexcoders@yahoogroups.com, "Tracy Spratt" <tr...@...> wrote: > > Sorry, no magic sauce here. I had some pixie dust somewhere, but. Was it > Asimov or Clark that said, "Any sufficiently advanced technology is > indistinguishable from magic"? > > > > When I needed a variable height renderer, I copied ListItemRenderer and > modified to my needs. That was the only way I could get it to work. It is > also *much* more performant than a container based renderer. The magic is > indeed in the measure() function. > > > > If you do not have a lot of items to renderer, Repeater works well with > variable heights. > > > > Tracy Spratt, > > Lariat Services, development services available > > _____ > > From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On > Behalf Of wubac1 > Sent: Saturday, April 18, 2009 2:02 AM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] Custom List ItemRenderer / Recycling troubles (height > incorrect) > > > > > > > > > I'm attempting to create a very simple item renderer for mx:List. I've found > that when the dataProvider is static, there are no problems with the custom > item > renderer. However, when the dataProvider is dynamic, the height of the item > renderer is not correct (and scroll bars appear for each renderer with any > meaningful # of rows). I've set variableRowHeight="true" for the List. I've > also tried overriding the measure function and invaliding the size when a > dataChange event is dispatched (based on information provided on FlexCoders > in previous discussions along these lines). > > CommentRenderer.mxml: > > <?xml version="1.0" encoding="utf-8"?> > <mx:VBox xmlns:mx="http://www.adobe. <http://www.adobe.com/2006/mxml> > com/2006/mxml" width="100%"> > <mx:Script> > <![CDATA[ > override protected function measure():void > { > super.measure(); > measuredHeight = comment.textHeight; > } > ]]> > </mx:Script> > <mx:LinkButton label="{data.commenter.name}"/> > <mx:Text id="comment" width="100%" text="{data.comment}" > dataChange="invalidateSize()"/> > </mx:VBox> > > The mx:List definition: > > <mx:List id="comments" itemRenderer="com.test.CommentRenderer" width="100%" > height="100%"/> > > I've looked over the ListItemRenderer, but have so far been unable to glean > the > magic sauce that makes the item renderer function correctly when the control > recycles. Can someone explain / provide a functional example(s) with mx:Text > (ActionScript and MXML examples preferred, for completeness)? >