Have you tried using the string constants AS already has for colors?
Not sure if it'll solve anything, but might work better:
setStyle("color", (data.L0 != 'Y') ? "Red" : "Black");
And are you tracing data.L0 to make sure it is what you think it is?
Other than that, I've always used mx:component-based itemRenderers
rather than AS packages. Of course, they compile down into the exact
same thing, but I found the mx: components to be a little easier to debug.
Maybe using something like this would shed a little more light:
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Label color="{((data.L0!='Y')? 0xFF0000:0x000000)}"
text="{data.L0}" />
</mx:HBox>
Assigning this as an itemRenderer to a column works for me.
--- In [email protected], "jovialrandor" <[EMAIL PROTECTED]>
wrote:
>
> I have the following code that turns Datagrid cell to red if the
> value is not 'Y' for 'L0' attribute of the arraycollection object.
> However, when I run the program, it does not take effect.
>
> ---------------------------
>
> package {
> import mx.controls.Label;
> import mx.controls.listClasses.*;
>
> public class BItemRenderer extends Label {
>
> private const POSITIVE_COLOR:uint = 0x000000; // Black
> private const NEGATIVE_COLOR:uint = 0xFF0000; // Red
>
> override protected function updateDisplayList
> (unscaledWidth:Number, unscaledHeight:Number):void {
> super.updateDisplayList(unscaledWidth, unscaledHeight);
>
> /* Set the font color based on the item price. */
> setStyle("color", (data.L0 != 'Y') ? NEGATIVE_COLOR :
> POSITIVE_COLOR);
> }
> }
> }
>