tags:

views:

2460

answers:

3

I was able to set the text color of a selected LinkBar button by "disabledColor" style of LinkBar. Accordingly, I expect to set the background color of the selected button by "backgroundDisabledColor" style, however, it didn't work; and except "backgroundDisabledColor", I didn't see any other style that could possibly achieve this. Please help. Thanks.

+2  A: 

The problem is probably that you're setting the style on the LinkBar itself - try setting the LinkBar's linkButtonStyleName style to a different style selector that contains all of the styles you need for your button. You should be able to set the fillColors style of the buttons themselves there - this will change the default look of the button.

If you need to adjust the "selected" color or if you need something more advanced than just skinning the button background you'll need to write a custom skin class. This isn't too difficult - the Button class has a whole set of "Selected" styles - selectedDownSkin, selectedUpSkin, selectedDisabledSkin, etc. IMO the best practice is to set your button skin to a custom skin class that sets the different individual styles based on state.

David Flately illustrates this method here. Check out his source - that should get you what you need. A good book on this topic that has this sort of thing along with lots of other examples is Juan Sanchez and Andy McIntosh's Creating Visual Experiences with Flex 3.0. I can't post a link to it because my reputation isn't high enough here yet, but you can find it on amazon or barnes and noble or any other online bookstore.

RJ Owen
Many thanks. By following that link, it's fairly easy to write a programmatic skin and get the background colors fixed. In my case, I only need to consider 3 skins: disabledSkin, overSkin and skin. One thing that I noticed - it seems that LinkButton's selected and disabled styles are the same, because disabledSkin is the skin used when I make a LinkBar selection. So there will be no visual way to tell a selected button from a disabled button. Any idea?
Tong Wang
Yes - in your skin class you'll probably need to separate the disabled and selected skins into two different implementations, even though the default is to display them in the same way.
RJ Owen
A: 

Haha, was looking for same thing, you can see on the source code of LinkBar:

    // Hilite the new selection.
    child = Button(getChildAt(selectedIndex));
    child.enabled = false;

Which is clever!!! Rather than set selected to true, they disable the selected button ... why not ;-( Took me half an hour to understand the Flex team logical ...

eBuildy, Flex Specialists

eBuildy