Guy,  thank you very much for that answer.  Did some googling on dataChange and 
found this useful note 
http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_7.html

--- In [email protected], Guy Morton <g...@...> wrote:
>
> itemRenderers get reused, so you need to use the dataChange event to  
> ensure you set the renderer to the right state for each new set of data.
> 
> I use the creationComplete event to initialise anything that can span  
> datasets, and the dataChange event to reconfigure the renderer for the  
> current data.
> 
> Guy
> 
> 
> On 30/03/2009, at 4:24 PM, valkyrie77 wrote:
> 
> > Hi folks,
> >
> > I have a custom item renderer (see code attached below) that looks  
> > at a data subset and determines whether there exist a URL in it or  
> > not. If there does exist a URL, the item renderer sets a new bg  
> > color style for itself.
> >
> > The item renderer is assigned to a list. Issue is when the  
> > dataprovider to the list is modified and refresh, seems like the  
> > formatting sticks to the same cell but new information is in the cell.
> >
> > Is there a clenup function i should be running on the list or  
> > itemrenderers after my dataprovider is refreshed?
> >
> > Thanks,
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml";  
> > cornerRadius="0" width="375" height="89" borderStyle="solid"  
> > backgroundColor="#3E3E3E" borderColor="#000000"  
> > creationComplete="{determineURL(data._itemTitle)}">
> > <mx:Style>
> > .hrRule
> > {
> > border-bottom: dashed 2px #0066cc;
> > }
> > .twBody
> > {
> > font-family: Arial, sans-serif;
> > font-size: 11px;
> > line-height: 18px;
> >
> > }
> >
> > .twSig
> > {
> > font-family: Arial, sans-serif;
> > font-size: 10px;
> > font-style: italic;
> > line-height: 18px;
> > }
> > </mx:Style>
> > <mx:Script>
> > <![CDATA[
> > private var _msInMinute:Number = 1000 * 60;
> > [Bindable]
> > public var _itemTitle:String;
> > [Bindable]
> > public var _itemInfo:String;
> > [Bindable]
> > public var _itemtimeStamp:String;   
> > [Bindable]
> > public var _itemThumb:String;
> > [Bindable]
> > public var _itemAuthor:String;
> > [Bindable]
> > public var _itemID:Number;
> > [Bindable]
> > public var _itemType:String;
> >
> > // Regular Expression
> > private var urlMatch:RegExp = /[^"|^>](http:\/\/+[\S]*)/gi;
> > private var twitPicMatch:RegExp = /[^"|^>](http:\/\/twitpic.com+ 
> > [\S]*)/gi;
> >
> > public function determineURL(itemTitle:String):void {
> > trace("FIGURING OUT IF ITS A URL");
> > if (itemTitle.search(urlMatch) >= 0) {
> > //newURL = "URL IS HERE";
> > this.setStyle("backgroundColor", "0x687B8C");
> > //this.height = 249;
> > } else if (itemTitle.search(twitPicMatch) >= 0) {
> > //newURL = "URL IS HERE";
> > this.setStyle("backgroundColor", "0x687EEE");
> > //this.height = 249;
> > } else {
> > this.setStyle("backgroundColor", "0x3E3E3E");
> > }
> > /*
> > if (itemTitle.search(urlMatch) >= 0) {
> > //newURL = "URL IS HERE";
> > this.setStyle("backgroundColor", "0x687B8C");
> > //this.height = 249;
> > }*/
> > //itemTitle = itemTitle + " " + newURL;
> > }
> >
> > public function determineHowLong(targetDate:Number,  
> > sourceDate:Number):void
> > {
> > trace(">>determineHowLong");
> > var howLong:String = new String("n/a");
> > var MSdifference:Number = sourceDate - targetDate;
> > this._itemInfo = determineMinutes(MSdifference) + " minutes ago";
> > //return howLong;   
> > }
> >
> > private function tellTime(epochTime:Number):String {
> > var time:String = "";
> > var tempDate:Date = new Date(epochTime);
> > time = tempDate.getHours() + ":" + tempDate.getSeconds();
> > trace(">>tellTime " + time);
> > return time;
> > }
> >
> > private function msgType(type:String):String {
> > var msg:String = "";
> > switch(type) {
> > case "timeline":
> > msg = "G";
> > break;
> > case "dm":
> > msg = "D";
> > break;
> > case "search":
> > msg = "S";
> > break;
> > }
> > return msg;
> > }
> >
> > private function determineMinutes(miliSecs:Number):Number {
> > trace(">>determineMinutes");
> > var minuteDiff:Number = 0;
> > minuteDiff = Math.round(miliSecs / _msInMinute);
> > return minuteDiff
> > }
> >
> > ]]>
> > </mx:Script>
> >
> > <!--<mx:Label id="itemTitle_lbl" x="10" y="10" width="350"  
> > color="#EDEAEA" text="{itemTitle}" height="46" fontFamily="Arial"  
> > fontSize="11" />-->
> > <mx:Text x="40" y="0" width="323" height="57" color="#F3F4F4"  
> > fontFamily="Arial" fontSize="11" htmlText="{data._itemTitle}"  
> > styleName="twBody" id="itemtit"/>
> > <mx:Text x="40" y="55" width="325" height="18" color="#E3E6E6"  
> > fontFamily="Arial" fontSize="10" text="ago by {data._itemAuthor}"  
> > textAlign="right"/>
> > <mx:Text x="10" y="13" width="22" id="_typed"  
> > text="{msgType(data._itemType)}"/>
> > </mx:Canvas>
> >
> >
> >
>


Reply via email to