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.

 
Tagged with:
 
About The Author

Peter deHaan

Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.

0 Responses to Changing a Flex ProgressBar control’s direction

  1. Kamal says:

    How to install flex 4.0 / flex gumbo

  2. Peter deHaan says:

    Kamal,

    For more information on downloading and installing the Gumbo SDK into Flex Builder 3, see “Using the beta Gumbo SDK in Flex Builder 3″.

    Peter

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree