Jump to content

How to Set the Selected Color of Flex LinkBar

0
  todisht's Photo
Posted Nov 26 2009 05:29 PM

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<event.target.numChildren; i++){      
       var curItem = event.target.getChildAt(i);
       i==event.index ? curItem.setStyle("color", 0x2a80d5) : curItem.setStyle("color", 0x000000);     
    }
}


Tags:
0 Subscribe


2 Replies

 : Aug 31 2010 01:20 AM
hello thanks for sharing this great method of Set the Selected Color of Flex LinkBar,

i was tried to Set the Selected backgroundColor of Flex LinkBar, i replaced "color" of

"backgroundColor", but it doesn't work...

could you share the method of set the selected background color?

thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 : Sep 02 2010 01:51 PM
Just wanted to say a big thanks for this method sorted my nav right out :-)