R – Flex Button with one color on left & another on right

actionscript-3apache-flexflex3

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.

Best Answer

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).

Related Topic