Flex中如何通过设置textAlign样式设定DateField中选中日期对齐方式的例子
2009-11-11 14:57
886 查看
接下来的例子演示了如何通过设置textAlign样式,设定DateField中选中日期对齐方式。
下面是完整代码(或点击这里察看):
Download: main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="top"
backgroundColor="white">
<mx:Script>
<![CDATA[
import mx.events.ItemClickEvent;
private function init():void {
dateField.selectedDate = new Date();
}
private function toggleButtonBar_itemClick(evt:ItemClickEvent):void {
dateField.setStyle("textAlign", evt.item.label);
}
]]>
</mx:Script>
<mx:ApplicationControlBar dock="true">
<mx:ToggleButtonBar id="toggleButtonBar"
selectedIndex="1"
itemClick="toggleButtonBar_itemClick(event);">
<mx:dataProvider>
<mx:Array>
<mx:Object label="left" />
<mx:Object label="center" />
<mx:Object label="right" />
</mx:Array>
</mx:dataProvider>
</mx:ToggleButtonBar>
</mx:ApplicationControlBar>
<mx:DateField id="dateField"
width="200"
textAlign="center"
initialize="init();" />
</mx:Application>
让我们先来看一下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="top"
backgroundColor="white">
<mx:Script>
<![CDATA[
import mx.events.ItemClickEvent;
private function init():void {
dateField.selectedDate = new Date();
}
private function toggleButtonBar_itemClick(evt:ItemClickEvent):void {
dateField.setStyle("textAlign", evt.item.label);
}
]]>
</mx:Script>
<mx:ApplicationControlBar dock="true">
<mx:ToggleButtonBar id="toggleButtonBar"
selectedIndex="1"
itemClick="toggleButtonBar_itemClick(event);">
<mx:dataProvider>
<mx:Array>
<mx:Object label="left" />
<mx:Object label="center" />
<mx:Object label="right" />
</mx:Array>
</mx:dataProvider>
</mx:ToggleButtonBar>
</mx:ApplicationControlBar>
<mx:DateField id="dateField"
width="200"
textAlign="center"
initialize="init();" />
</mx:Application>
相关文章推荐
- Flex的NumericStepper控件中如何通过textAlign样式设置文本对齐方式的例子
- Flex中如何通过tabStyleName, tabWidth和textAlign样式,设置TabBar控件内文本对齐方式
- Flex中通过设置textAlign和labelStyleName样式设置FormItem容器中标签文本对齐方式的例子
- Flex中通过设置textAlign和headerStyleName样式设置DateChooser控件头部年月文本对齐方式的例子
- Flex中通过textAlign样式在一个按钮(Button)控件中设置标签(label)对齐方式的例子
- Flex中通过设置textAlign样式在一个List控件中改变文本对齐方向的例子
- Flex中如何通过itemRollOverColor和itemSelectionColor样式给列图ColumnChart设置选中/未选颜色的例子
- Flex中如何通过selectionColor和selectionDisabledColor样式设置DataGrid的行选中与无效时颜色的例子
- Flex中如何通过borderColor样式设置DateField控件边框颜色的例子
- Flex中如何通过selectedButtonTextStyleName样式,设置ToggleButtonBar选中按钮文本颜色
- Flex的Accordion控件中如何通过设置openDuration样式设定打开/切换的时间长短的例子
- Flex中如何通过设置cornerRadius样式设定NumericStepper控件边缘棱角圆滑幅度(corner radius)的例子
- Flex中如何通过leading样式在一个text控件中设置文本铅框(text leading)的例子
- Flex中如何通过设置tickLength样式设定HSlider控件上一个标记号(tick)长度的例子
- Flex中如何通过设置selectedDate属性设定DateChooser控件中被选择日期的例子
- Flex中如何通过设置separatorWidth样式来设定LinkBar控件各项目间分隔宽度的例子
- Flex 4中如何设置TextFlow内超链接样式的例子
- Flex中如何通过getHeaderAt()函数以及selectedUpIcon,selectedOverIcon和selectedDownIcon样式给Accordion头部设置一个分割用图标的例子
- Flex中如何通过paddingTop样式设置TabNavigator控件内容与Tabs间距离的例子
- Flex Gumbo中如何通过contentBackgroundColor样式,设置TextInput内文本背景颜色