Hi guys,
I've been searching a solution to this for a whole day and I have yet to find it.
I have a tileList in which I have overrided the methods
drawHighlightIndicator (the mouse over background graphic) and
drawSelectionIndicator (the selected tile background graphic). These work perfect.
However, I want to have a tile background graphic in normal state, too (when the item is not highlighted nor selected). I have to say that in this case, the "alternating item color" is not an option for me, because i am drawing a custom graphic (rounded rectangle of certain dimensions and colors, depending on the tile index).
I can't put a background to the ItemRenderer because then the highlight/selected colors don't show up anymore (they're "behind" the renderer);
I tried overriding the
drawTileBackground method but i'm getting no background at all.
Does anyone know what i have to do to achieve my goal? or a working example, that would be great.
This is what I have so far if it helps:
ActionScript Code:
/** mouse over skin **/
override protected function drawHighlightIndicator(indicator:Sprite, x:Number, y:Number, width:Number, height:Number, color:uint, itemRenderer:IListItemRenderer):void
{
var g:Graphics = Sprite(indicator).graphics;
g.clear();
g.beginFill(0x999999, 0.5);
g.drawRoundRect(2, 2, 40, 40, 10, 10);
g.endFill();
indicator.x = x;
indicator.y = y;
}
/** mouse down skin **/
override protected function drawSelectionIndicator(indicator:Sprite, x:Number, y:Number, width:Number, height:Number, color:uint, itemRenderer:IListItemRenderer):void
{
var g:Graphics = Sprite(indicator).graphics;
g.clear();
g.beginFill(0xAAAAAA, 1);
g.drawRoundRect(2, 2, 40, 40, 10, 10);
g.endFill();
indicator.x = x;
indicator.y = y;
}
/** i found this code somewhere but it does not work :( **/
override protected function drawTileBackground(s:Sprite, rowIndex:int, columnIndex:int, width:Number, height:Number, color:uint, item:IListItemRenderer):DisplayObject
{
color = 0xEEEEEE;
width = height = 40;
var tileBGIndex:int = rowIndex * columnCount + columnIndex;
var bg:Shape;
if (tileBGIndex < s.numChildren)
{
bg = Shape(s.getChildAt(tileBGIndex));
}
else
{
bg = new FlexShape();
bg.name = "tileBackground";
s.addChild(bg);
}
var g:Graphics = bg.graphics;
g.clear();
g.beginFill(color, 1);
g.drawRect(0, 0, width, height);
g.endFill();
return bg;
}