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.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)?


Reply via email to