简体   繁体   中英

Flex Button with one color on left & another on right

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.

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

你可以用degrafa来给按钮贴皮

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM