The other day while I was working on a project I found a problem with the my List’s ItemRenderer.
Here’s the situation: I had to use the ItemRenderer to display some htmlText in my List. Here’s the ItemRenderer that I came up with:
listRenderer.mxml
< ?xml version="1.0" encoding="utf-8"?> <mx:canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="240" height="50" creationComplete="init()"> <mx:script> < ![CDATA[ import mx.controls.Label; private function init() : void { rendererText.htmlText = '<b>' + data.title + '' + '\n'; rendererText.htmlText += 'meeting starts at: ' + data.time + '\n'; rendererText.htmlText += 'and lasts for: ' + '<i>' + data.duration + '</i>'; } ]]> </mx:script> <mx:text id="rendererText" textAlign="left"></mx:text> </mx:canvas> |
But when I updating my dataProvider I found that the List was not updating along with my dataProvider. I checked everything over and over again until the only thing left that could still cause problems was the ItemRenderer itself.
As it turns out you should never use the creationComplete event with ItemRenderers.
After I rewrote my ItermRenderer everything worked as I expected:
Read the rest of this entry »