Robertopriz’s Weblog

Change default background color for selected item in TileList component

Posted in blogging to don't google by robertopriz on June 5, 2009

To change default selectedItem color you need to override a couple of methods extending TileList:

import flash.display.Graphics;
import flash.display.Sprite;

import mx.controls.TileList;
import mx.controls.listClasses.IListItemRenderer;

public class TileLsitEx extends TileList{

public function TileLsitEx()
{
super();
}
override protected function drawSelectionIndicator(indicator:Sprite, x:Number, y:Number,  width:Number, height:Number, color:uint,
itemRenderer:IListItemRenderer):void   {
var g:Graphics = indicator.graphics;
g.clear();
g.beginFill(0x3f4c6b);
g.lineStyle(2,0x6e7c9d);
g.drawRoundRect(x,y,itemRenderer.width,height,15,15);
g.endFill();
return;
}

override protected function drawHighlightIndicator(indicator:Sprite, x:Number, y:Number,width:Number, height:Number, color:uint,
itemRenderer:IListItemRenderer):void   {
return;
var g:Graphics = indicator.graphics;
g.clear();
g.beginFill(0x3f4c6b);
g.lineStyle(2,0x6e7c9d);
g.drawRoundRect(x,y,itemRenderer.width,height,15,15);
g.endFill();
}
}

Advertisements