22
Aug
07

Using overlapping slider thumbs in the Flex Slider controls

I was playing around with the HSlider component tonight and was checking out the allowThumbOverlap property. The following example creates a horizontal slider with 2 slider thumbs and lets you toggle the allowThumbOverlap property with the showTrackHighlight property set to true.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/08/22/using-overlapping-slider-thumbs-in-the-flex-slider-controls/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            private function list_labelFunc(item:Object):String {
                return Number(item).toFixed(2);
            }
        ]]>
    </mx:Script>

    <mx:Number id="slider_thumbCount">2</mx:Number>

    <mx:ApplicationControlBar dock="true">
        <mx:CheckBox id="checkBox"
                label="allowThumbOverlap"
                selected="true" />
    </mx:ApplicationControlBar>

    <mx:HSlider id="slider"
            allowThumbOverlap="{checkBox.selected}"
            dataTipPrecision="2"
            showTrackHighlight="true"
            snapInterval="0.25"
            thumbCount="{slider_thumbCount}"
            tickInterval="1" />

    <mx:List id="list"
            dataProvider="{slider.values}"
            labelFunction="list_labelFunc"
            rowCount="{slider_thumbCount}"
            width="{slider.width}" />

</mx:Application>

View source is enabled in the following example.


3 Responses to “Using overlapping slider thumbs in the Flex Slider controls”


  1. 1 Kiruthika Apr 24th, 2008 at 2:45 am

    hi,

    This is really cool. I am very new to Flex, could you tell what has to be done in order to use this in a program.

    Thanks,
    Kiruthika

  2. 2 peterd Apr 24th, 2008 at 8:38 am

    Kiruthika,

    In Flex Builder, create a new Flex Project by selecting File > New > Flex Project from the main menu. Enter a Project name and click “Finish”. Copy and paste the code from above and paste into the MXML file in your Flex project. Finally, select Run > Run <project name> from the main menu to view the Flex application in a web browser.

    Peter

  3. 3 Jeff Jun 3rd, 2008 at 8:11 am

    Hi Peter,

    I was wondering if you knew how to position the Thumbs so that they are at each end of the slider? For example on a single thumb slider you could use value=10.

    Thanks,
    jeff

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;".