Flex中如何通过buttonStyleName, fillColors和fillAlphas样式改变ButtonBar背景填充颜色的例子
By Minidxer | January 25, 2009
接下来的例子演示了Flex中如何通过buttonStyleName, fillColors和fillAlphas样式,改变ButtonBar背景填充颜色。
让我们先来看一下Demo(可以右键View Source或点击这里察看源代码):
下面是完整代码(或点击这里察看):
Download: main.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white">
- <mx:Style>
- .allButtons2 {
- /* Creates a gradient from red/orange when button is in the
- "out" state. */
- fillColors: red, haloOrange;
- }
- .allButtons4 {
- /* Creates a gradient from red/orange when button is in the
- "out" state. Creates a gradient from green/blue when
- button is in the "over" state. */
- fillColors: red, haloOrange, haloGreen, haloBlue;
- }
- .allButtonsSolid {
- fillColors: red, red;
- }
- .allButtonsSolidOpaque {
- fillAlphas: 1.0, 1.0;
- fillColors: red, red;
- }
- </mx:Style>
- <mx:ViewStack id="viewStack"
- visible="false"
- includeInLayout="false">
- <mx:VBox label="One">
- <mx:Label text="One" />
- </mx:VBox>
- <mx:VBox label="Two">
- <mx:Label text="Two" />
- </mx:VBox>
- <mx:VBox label="Three">
- <mx:Label text="Three" />
- </mx:VBox>
- </mx:ViewStack>
- <mx:Form>
- <mx:FormItem label="2 fill colors defined:">
- <mx:ButtonBar id="buttonBar2"
- buttonStyleName="allButtons2"
- dataProvider="{viewStack}" />
- </mx:FormItem>
- <mx:FormItem label="4 fill colors defined:">
- <mx:ButtonBar id="buttonBar4"
- buttonStyleName="allButtons4"
- dataProvider="{viewStack}" />
- </mx:FormItem>
- <mx:FormItem label="solid fill:">
- <mx:ButtonBar id="buttonBarSolid"
- buttonStyleName="allButtonsSolid"
- dataProvider="{viewStack}" />
- </mx:FormItem>
- <mx:FormItem label="solid opaque fill:">
- <mx:ButtonBar id="buttonBarSolidOpaque"
- buttonStyleName="allButtonsSolidOpaque"
- dataProvider="{viewStack}" />
- </mx:FormItem>
- </mx:Form>
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
ButtonBar |
1 Comment » |
Tags: ButtonBar, buttonStyleName, fillAlphas, fillColors
? is there a problem,the swf doesn’t match to the code.