Set Selected Color of LinkBar

November 30th, 2007 § 1 comment

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);     }   }


Digg!

§ One Response to Set Selected Color of LinkBar

  • riccardo says:

    thanks a lot!!!
    i’ve been looking for a quick and easy solution to this problem for looooooong!!!
    thank you!
    this is perfect and very easy!
    bye.
    r.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

What's this?

You are currently reading Set Selected Color of LinkBar at T3B.

meta