The following example shows how you can display scroll tips in a Flex HorizontalList control by setting the Boolean showScrollTips property.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/01/04/displaying-scroll-tips-in-a-horizontallist-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<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:HorizontalList id="horizontalList"
dataProvider="{arr}"
columnWidth="175"
columnCount="3"
rowCount="1"
rowHeight="100"
showScrollTips="true" />
</mx:Application>
View source is enabled in the following example.
If you want to customize the scroll tip’s appearance, you can set the ToolTip style in an external .CSS file or <mx:Style /> block, as shown in the following snippet:
<mx:Style>
ToolTip {
backgroundColor: haloBlue;
color: white;
fontWeight: bold;
}
</mx:Style>
If you want to customize the scroll tip’s text, you can set the scrollTips property to true and set the scrollTipFunction property, as shown in the following example:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/01/04/displaying-scroll-tips-in-a-horizontallist-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Style>
ToolTip {
backgroundColor: haloBlue;
color: white;
fontWeight: bold;
}
</mx:Style>
<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:Script>
<![CDATA[
import mx.controls.listClasses.TileBaseDirection;
private function horizontalList_scrollTipFunc(direction:String, position:Number):String {
var str:String;
var max:Number;
var pct:String;
switch (direction) {
case TileBaseDirection.HORIZONTAL:
max = horizontalList.maxHorizontalScrollPosition;
break;
case TileBaseDirection.VERTICAL:
max = horizontalList.maxVerticalScrollPosition;
break;
}
pct = numberFormatter.format(position / max * 100);
str = position + " of " + max + " (" + pct + "%)";
return str;
}
]]>
</mx:Script>
<mx:NumberFormatter id="numberFormatter" precision="0" />
<mx:HorizontalList id="horizontalList"
dataProvider="{arr}"
columnWidth="175"
columnCount="3"
rowCount="1"
rowHeight="100"
showScrollTips="true"
scrollTipFunction="horizontalList_scrollTipFunc" />
</mx:Application>
View source is enabled in the following example.





0 Responses to “Displaying scroll tips in a HorizontalList control in Flex”
Leave a Reply