在FLEX的LIST组件中显示滚动条提示.
下面的例子通过设定LIST组件的
你也可以通过使用
showScrollTips
属性展示如何在FLEX的LIST组件中显示滚动提示.你也可以通过使用
scrollTipFunction属性来建立一个滚动条提示函数来自定义滚动条中的文本内容。
<?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>
翻译自:http://blog.flexexamples.com/2008/03/28/displaying-scroll-tips-in-a-list-control-in-flex/#more-576