The following example shows how you can change whether a ProgressBar control fills from left-to-right or right-to-left by changing the direction property to one of the static constants in the mx.controls.ProgressBarDirection class.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/10/07/changing-a-flex-progressbar-controls-direction/ -->
<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>
View source is enabled in the following example.




0 Responses to “Changing a Flex ProgressBar control's direction”
Leave a Reply