07
Oct
07

Changing a Flex ProgressBar control’s direction

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.

View MXML

<?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”


  1. No Comments

Leave a Reply

This blog is terrible at eating HTML tags. If you plan on posting code/XML, please escape your "<" characters as "&lt;" and your ">" characters as "&gt;".




Badge Farm

  • Firefox 2
  • Powered by Redoable 1.2
  • Feeds burnt by Feedburner
  • Feed