I want to get rid of the typical Flex roll-over color in list-based components, and to display my own style of roll-over rendering.
Setting useRollOver to 'false' is not an option, since disabling that will also make the List.isItemHighlighted() function to always return false. My custom renderer relies on that function.
Can it be so hard? Is there no way of setting that roll-over color to transparent? Is there some other way for my renderer to figure out if an item is highlighted?
Thanks!
EDIT: Of course I could set the rollOver color to 'white' and set the alternatingRowColors to something similar to white. Kind of cheating :)
@invertedSpear, thanks for your hint.
It actually works! I mean, subclassing, not editing the SDK, haven't tried that. But what you can do is to create a subclass for a List, DataGrid etc (or even AdvancedDataGrid) and add the following function:
override protected function drawHighlightIndicator(indicator:Sprite, x:Number, y:Number, width:Number,
height:Number, color:uint, itemRenderer:IListItemRenderer):void
{
// get style -- is this the right place?
var alpha:Number = this.getStyle("rollOverAlpha");
if (isNaN(alpha))
alpha = 1.0;
// no need to draw if alpha 0
if (alpha <= 0)
return;
// draw -- this has been copied from superclass, and the alpha parameter added to beginFill()
var g:Graphics = Sprite(indicator).graphics;
g.clear();
g.beginFill(color, alpha);
g.drawRect(0, 0, width, height);
g.endFill();
indicator.x = x;
indicator.y = y;
}
Now if you add a style declaration to the class, you are ready to roll:
[Style(name="rollOverAlpha", type="Number", inherit="no")]
public class DataGridExt extends DataGrid
{
...
}
Changing this in the SDK would of course be a better choice since you would only have to touch two classes: ListBase and AdvancedListBase. I'll check for an Adobe Jira Issue on that..