The value parameter in the data setter should have valid values, but at startup 
it might get passed an unexpected value.  I'd just check to make sure the data 
is valid and ignore bad data and see if you get further and get valid values 
later.

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Cordova 
Aaron
Sent: Friday, September 12, 2008 4:17 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] mx:List and custom item background colors


I have been working at this for a few hours now. I have seen examples for 
several list controls other than just mx:List.

I thought this example was the most promising to accomplish what I am trying to 
do.

<mx:itemRenderer>
<mx:Component>
<mx:HBox paddingLeft="2">
<mx:Script>
<![CDATA[
override public function set data( value:Object ) : void {
super.data = value;
var today:Number = (new Date()).time;
var pubDate:Number = Date.parse(data.date);
if( pubDate > today ) setStyle("backgroundColor",0xff99ff);
else setStyle("backgroundColor",0xffffff);
}
]]>
</mx:Script>
<mx:Image source="{data.image}" width="50" height="50" scaleContent="true" />
<mx:Text width="100%" text="{data.title}" />
</mx:HBox>
</mx:Component>
</mx:itemRenderer>

But this example is from a dataGrid and the var value has no value when using 
this method in
a mx:List control.

All I want to do is change the bacground color of the mx:HBox dependent on 
another value from
data.

Any ideas?

Reply via email to