Hi, Tim.

Thanks for a great example.

R.

On 12/18/06, Tim Hoff <[EMAIL PROTECTED]> wrote:

  Sorry that didn't work for you Roman.  Here's an older example that has
an itemRenderer that changes the color of the text; based on the value of
the data.  Hope that it helps.

Sample<http://www.cflex.net/showFileDetails.cfm?ObjectID=443&Object=File&ChannelID=1>


Cheers,
-TH

--- In flexcoders@yahoogroups.com, "Roman Protsiuk" <[EMAIL PROTECTED]>
wrote:
>
> Hi, Tim.
>
> Thanks for the advise. Though, it didn't help. Even calling
> super.invalidateDisplayList() I get no color change.
>
> R.
>
> On 12/16/06, Tim Hoff [EMAIL PROTECTED] wrote:
> >
> > Hi Roman,
> >
> > After you conditionally change the color, you have to redraw the
> > itemRenderer. Try this:
> >
> > [Bindable] public var highlightColor : uint = 0x000000;
> >
> > public override function set data(value : Object) : void
> > {
> > super.data = value;
> >
> > if (value != null)
> > {
> > if (!value.valid) highlightColor = 0xFF0000;
> > }
> > super.invalidateDisplayList();
> > }
> >
> > <mx:Label color="{highlightColor}"/>
> >
> > -TH
> > __________________________________
> >
> > *Tim Hoff
> > *Cynergy Systems, Inc.
> > http://www.cynergysystems.com <http://www.cynergysystems.comoffice/>

> > Office: 866-CYNERGY
> >
> > --- In flexcoders@yahoogroups.com, "Roman Protsiuk" roman.protsiuk@
> > wrote:
> > >
> > > Hi.
> > >
> > > I am using item renderer for DataGrids column (for example) derived
> > > from DataGridItemRenderer. The data sent to item renderer has a
> > > boolean property named "valid". If valid == true I want the label to
> > > be red otherwise black. The problem is when I'm using direct
> > > assignment textColor = 0xFF0000; the text doesn't become red. When
I'm
> > > using data binding (with data.valid == false) like
> > > <mx:DataGridItemRenderer ... textColor="{highlightColor}">... Where
> > > highlightColor is, for example:
> > >
> > > [Bindable]
> > > public var highlightColor : Number;
> > >
> > > public override function set data(value : Object) : void {
> > > if (value != null && value.valid) {
> > > highlightColor = 0x000000;
> > > } else {
> > > highlightColor = 0xFF0000;
> > > }
> > > super.data = value;
> > > }
> > >
> > > the text still DOESN'T become red.
> > >
> > > However if to derive renderer from any container, say Canvas, and
> > > insert Label into that container like:
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml";>
> > > <mx:Label color="{highlightColor}" ... />
> > > </mx:Canvas>
> > >
> > > with the same highlightColor everything works -- text DOES become
red.
> > > I've faced the same behavior in many situations related to item
> > > renderers and list-based controls. E.g. CheckBox or RadioButton need
> > > to be initially checked inside of a list. Every time had to use this
> > > "itemRenderer = control inside of a container + bindable data;"
> > > approach to make it work.
> > >
> > > Can't understand why... Seems to me that described above approach is
> > > way to strained. There should be more native one.
> > >
> > > Appreciate any help,
> > > R.
> > >
> >
> >
> >
>

Reply via email to