1 Reply Latest reply on Jul 15, 2007 10:23 AM by :JT:

    Using a custom item renderer and textSelectedColor


      I am using a custom item renderer and am trying to figure out how i can capture/set some Label controls that are in this renderer using the textSelectedColor style property.

      I have a List control, and the item renderer is basically this:

      <mx:Label id="someLabel" />

      With quite a few more controls, but that's the jist of it.

      When an item is selected in the list i want to change the color of that Label, now i have tried a number of ways but none that i like, for example i can set an event handler from the ListEvent.CHANGE and do if(this == event.itemRenderer) but if the it loses focus for whatever reason it doesn't get updated i would have to add a focus handler to... it just seems hacked.

      So my question is how can i properly check style changes on the List to send down to my item renderer? Specifically the textSelectedColor. Other styles like alternatingItemColors, selectionColor, etc... work without any custom code for it; btw.

      Thanks for the help.

      - Justin
        • 1. Re: Using a custom item renderer and textSelectedColor
          :JT: Level 1
          Got it figured out...

          protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
          super.updateDisplayList(unscaledWidth, unscaledHeight);

          if(this.data != null && this.parent != null)
          var c:Number = 0;
          var listOwner:List = List(this.owner);

          c = this.getStyle("disabledColor");
          else if(listOwner.isItemHighlighted(this.data))
          c = this.getStyle("textRollOverColor");
          else if(listOwner.isItemSelected(this.data))
          c = this.getStyle("textSelectedColor");
          c = this.getStyle("color");

          lblDate.setStyle("color", c);
          lblInstructorName.setStyle("color", c);
          lblCourseName.setStyle("color", c);