Flex中如何利用labelStyleName样式设置FormItem容器个别标签颜色的例子
By Minidxer | November 24, 2008
接下来的例子演示了Flex中如何利用labelStyleName样式,设置FormItem容器个别标签颜色。
让我们先来看一下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 source="embeddedFonts.css" />
- <mx:Style>
- Form {
- fontFamily: ArialEmbedded;
- }
- FormHeading {
- color: haloSilver;
- fontSize: 24;
- }
- FormItem {
- labelStyleName: defaultLabel;
- }
- .defaultLabel {
- color: black;
- fontSize: 10;
- fontStyle: italic;
- fontWeight: normal;
- }
- .requiredLabel {
- color: red;
- fontSize: 12;
- fontWeight: bold;
- }
- </mx:Style>
- <mx:String id="str">
- <![CDATA[The quick brown fox jumped over the lazy dog.]]>
- </mx:String>
- <mx:Form>
- <mx:FormHeading label="Some form heading!" />
- <!-- override the default labelStyleName for the FormItem -->
- <mx:FormItem label="Field 1:"
- labelStyleName="requiredLabel"
- required="true">
- <mx:Label id="lbl1" text="{str}" />
- </mx:FormItem>
- <!-- override the default labelStyleName for the FormItem -->
- <mx:FormItem label="Field 2:"
- labelStyleName="requiredLabel"
- required="true">
- <mx:Label id="lbl2" text="{str}" />
- </mx:FormItem>
- <!-- default -->
- <mx:FormItem label="Field 3:">
- <mx:Label id="lbl3" text="{str}" />
- </mx:FormItem>
- <!-- default -->
- <mx:FormItem label="Field 4:">
- <mx:Label id="lbl4" text="{str}" />
- </mx:FormItem>
- </mx:Form>
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
FormItem |
No Comments » |
Tags: Form, FormHeading, FormItem, labelStyleName