3 Replies Latest reply on Aug 11, 2011 4:58 PM by Francisc

    Disable down and selected colour changing for IconItemRenderer

    Francisc Level 3

      Hello,

       

      I am trying to not show any graphical change when the user clicks/taps an IconItemRenderer with no decorator.

       

      What am I doing wrong here, please?

       

      override protected function drawBackground(unscaledWidth:Number,unscaledHeight:Number):void
      {
          if(data.decorator || (!down && !selected && !hovered))
          {
              super.drawBackground(unscaledWidth,unscaledHeight);
          }
      }

       

      If there is a decorator, call the super method - I don't want to change anything here.

      If the state is neither down, selected or hovered, also call the super method.

       

      The way I am doing it now is:

       

      if(data.decorator)
      {
          super.drawBackground(unscaledWidth,unscaledHeight);
      }
      else
      {
          //Background
          graphics.beginFill(0xFFFFFF,1);
          graphics.lineStyle();
          graphics.drawRect(0,0,unscaledWidth,unscaledHeight);
          graphics.endFill();
         
          //Separator
          graphics.beginFill(0xB3B3B3,1);
          graphics.drawRect(0,unscaledHeight-1,unscaledWidth,1);
          graphics.endFill();
      }

       

      Is there a better way?