Controlling the distance between tabs in a TabBar control using the horizontalGap style

The following example shows how you can control the spacing between tabs in a Flex TabBar control by setting the horizontalGap style.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/11/02/controlling-the-distance-between-tabs-in-a-tabbar-control-using-the-horizontalgap-style/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Array id="arr">
        <mx:Object label="The quick" />
        <mx:Object label="brown fox" />
        <mx:Object label="jumped over" />
        <mx:Object label="the lazy fox" />
    </mx:Array>

    <mx:ApplicationControlBar dock="true">
        <mx:Form>
            <mx:FormItem label="horizontalGap:">
                <mx:HSlider id="slider"
                        minimum="-5"
                        maximum="10"
                        value="-1"
                        liveDragging="true"
                        snapInterval="1"
                        tickInterval="1" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>

    <mx:TabBar id="tabBar"
            horizontalGap="{slider.value}"
            dataProvider="{arr}" />

</mx:Application>

View source is enabled in the following example.

One thought on “Controlling the distance between tabs in a TabBar control using the horizontalGap style

Comments are closed.