Flex中如何通过mx.controls.ProgressBarDirection类设置进度条(ProgressBar)是left-to-right还是right-to-left的例子
By Minidxer | October 15, 2008
有人吃饭用左手,有人吃饭用右手,那为什么进度条就非要从左往右呢?当然没人这样规定,接下来的例子演示了Flex中如何通过mx.controls.ProgressBarDirection类设置进度条(ProgressBar)是left-to-right还是right-to-left。
让我们先来看一下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:Script>
- <![CDATA[
- import mx.events.SliderEvent;
- import mx.controls.ProgressBarDirection;
- private function slider_change(evt:SliderEvent):void {
- progressBar.setProgress(slider.value, slider.maximum);
- }
- ]]>
- </mx:Script>
- <mx:Array id="arr">
- <mx:Object label="{ProgressBarDirection.LEFT}" />
- <mx:Object label="{ProgressBarDirection.RIGHT}" />
- </mx:Array>
- <mx:ApplicationControlBar dock="true">
- <mx:Form>
- <mx:FormItem label="direction:">
- <mx:ComboBox id="comboBox"
- dataProvider="{arr}"
- selectedIndex="1" />
- </mx:FormItem>
- <mx:FormItem label="value:"
- direction="horizontal">
- <mx:HSlider id="slider"
- minimum="0"
- maximum="100"
- liveDragging="true"
- change="slider_change(event);"
- dataTipPrecision="0"
- snapInterval="1"
- tickInterval="10" />
- <mx:Label text="{slider.value}" />
- </mx:FormItem>
- </mx:Form>
- </mx:ApplicationControlBar>
- <mx:ProgressBar id="progressBar"
- mode="manual"
- direction="{comboBox.selectedItem.label}" />
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
ProgressBar |
No Comments » |
Tags: direction, ProgressBar, ProgressBarDirection