Changing a Flex ProgressBar control’s direction

by Peter deHaan on October 7, 2007

in ProgressBar, ProgressBarDirection

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.

{ 2 comments… read them below or add one }

1 Kamal March 12, 2009 at 5:37 am

How to install flex 4.0 / flex gumbo

Reply

2 Peter deHaan March 12, 2009 at 7:58 am

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

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can 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

Previous post:

Next post: