views:

488

answers:

3

I have a Flex button. I need one color on the left and another on the right. I don't need it to be a gradient. Just solid colors. Like green on left & red on right. I really don't want to use an image -- just because it'll probably take me a long time to do it.

The gradients via Flex Properties in Flex Builder seems to apply only vertically, not horizontally.

I also tried to make 2 button, each half width (of original), and putting it into a HBox & really packing them close so they'll look like a single button with 2 colors. It works OK, but I was thinking if there was a better way.

Thanks.

A: 

I think the proper way to do something like this is to create a custom component and then override the drawing method and draw in two colors, with the associated properties and such.

The solution you used is the simplest, so you should keep it like that unless you want to go through the trouble of creating the custom component (It's not THAT bad since Flex is open source and you can see how the original button is coded, and modify from there).

CookieOfFortune
A: 

you could use degrafa to skin the button

asawilliams
A: 

This link http://blog.timeister.com/2009/01/16/flex-custom-button-skin/ provides a nice way to do exactly what I wanted above. It needs 2 classes: one subclasses ButtonSkin & the other Button. Link them both via CSS and use them in mxml. Simple & easy.

sri
So, post the solution
zdmytriv