Friday, November 30, 2007

Set Selected Color of LinkBar

We recently needed to set the selected color of a LinkBar item. This happens automagically if you are using it with a ViewStack, we however were using an Array for our dataprovider and for whatever reason, that is not supported. Fortunately I was able to find this little function to fix the problem. It basically loops through the children of your LinkBar. If the item clicked matches the current child in the loop it sets the style to your selected color. Code is below.

private function doLinkBar(event):void{
for(var i:int=0; i<; i++){
var curItem =;
i==event.index ? curItem.setStyle("color", 0x2a80d5) : curItem.setStyle("color", 0x000000);


No comments: