The following example shows how you can display scroll tips in a Flex List control by setting the showScrollTips property. You can also customize the scroll tip text by setting a custom scroll tip function using the scrollTipFunction property.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/03/28/displaying-scroll-tips-in-a-list-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            import mx.controls.scrollClasses.ScrollBarDirection;
            import mx.utils.StringUtil;

            private function list_scrollTipFunc(dir:String, pos:Number):String {
                var pct:Number = pos / list.maxVerticalScrollPosition;
                return StringUtil.substitute("{0} / {1} ({2}%)",
                        pos, // current
                        list.maxVerticalScrollPosition, // max
                        numberFormatter.format(pct * 100) // percent
                    );
            }
        ]]>
    </mx:Script>

    <mx:NumberFormatter id="numberFormatter" precision="0" />

    <mx:Array id="arr">
        <mx:Object label="Accordion" />
        <mx:Object label="ApplicationControlBar" />
        <mx:Object label="Box" />
        <mx:Object label="Canvas" />
        <mx:Object label="ControlBar" />
        <mx:Object label="DividedBox" />
        <mx:Object label="Form" />
        <mx:Object label="FormHeading" />
        <mx:Object label="FormItem" />
        <mx:Object label="Grid" />
        <mx:Object label="HBox" />
        <mx:Object label="HDividedBox" />
        <mx:Object label="Panel" />
        <mx:Object label="TabNavigator" />
        <mx:Object label="Tile" />
        <mx:Object label="TitleWindow" />
        <mx:Object label="VBox" />
        <mx:Object label="VDividedBox" />
        <mx:Object label="ViewStack" />
    </mx:Array>

    <mx:ApplicationControlBar dock="true">
        <mx:CheckBox id="checkBox"
                label="showScrollTips:"
                labelPlacement="left"
                selected="true" />
    </mx:ApplicationControlBar>

    <mx:List id="list"
            dataProvider="{arr}"
            rowCount="6"
            showScrollTips="{checkBox.selected}"
            scrollTipFunction="list_scrollTipFunc"
            verticalScrollPolicy="on" />

</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.

5 Responses to Displaying scroll tips in a List control in Flex

  1. Rafael says:

    I don’t think this sample is working, I don’t see the scrolltip being displayed regardless of the checkbox status.

  2. peterd says:

    Rafael,

    I see the scroll tip in the example above (using WinXP/FP9,0,115,0/IE7). It’s a little hard to see since it is actually over the List control itself.

    Peter

  3. Arulmurugan says:

    Hi Peter

    I am using a multiselect listbox how will I access the values in another page (ASP) selected when the page is submitted.

    Based on the selection I need to select some records from database.

    If you need the source code I will send it to you

    Regards,
    Arulmurugan . T
    Web Developer

  4. Dewey says:

    I think the confusion on the tooltip not showing isn’t that it isn’t showing (it is), but the expectations. I was initially expecting to see content tooltips as I moused over ‘TabNavigator’, ‘Tile’, etc. What this is doing is adding Tooltips to the scroll bar — which is exactly what it says it is doing… lol

  5. Hi,

    Is there a way to modify the style of the scrollTip?
    I would like to enlarge it and give it some transparency.
    Besides, I would prefer it it were located at the left-end side of the list (or datagrid or whatever).

    Many thanks in advance for your advice.

    Best regards,
    Guillaume

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