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.

 
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.

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

  1. theLoggerGuy says:

    Peterd,

    this is a bit off topic, but I was wondering how you might go about moving the tab buttons from the top to the bottom of a TabNavigator. I have been hunting the web and I see a lot of people asking for the same thing, but no solution (except the one here: http://www.richinternetapps.com/archives/2005_04.html, which doesn’t work for Flex 3).

    Cheers.

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