Friday, July 27, 2007

Flex LinkButton : Background Color

This post is a variation on an earlier post where I talked about having no background on Flex's LinkButton rollover state. This post relates to a question I saw on a forum about how to set the color of the LinkButton's background in the up state (no rollover). The LinkButton by default sets it's background transparent when there is no user interaction. There isn't any style attribute you can use to directly change this behaviour. To override this behaviour you need to set a skin :

 LinkButton {
upSkin:Embed("up_skin.png");
over
Skin:Embed("over_skin.png");
down
Skin:Embed("down_skin.png");
}

In this example I'm using a graphic. But you could also use a Flash symbol (see earlier post). The behavior of the LinkButton's label is unchanged by skinning the component in this way making this quite a useful approach. But if you want your LinkButton to have a background and you set that with a skin then you might want to consider if it's not really a Button that you need. The Button provides more style options than the LinkButton and may therefore be easier for this sort of use.

5 comments:

Anonymous said...

Try this instead...

upSkin: ClassReference(null);
downSkin: ClassReference(null);
overSkin: ClassReference(null);
disabledSkin: ClassReference(null);

sudopeople said...

Try this instead...

Doesn't work for me ^

Anonymous said...

try

rollOverColor: nill;

it work great...

Vincent D. said...

Since the link button is transparent, I have been able to set a background color simply by putting the button inside a Canvas for which I have set a background color.

Anonymous said...

mx|LinkButton{
skin: ClassReference(null);
}