分页组件

以前写的一段Flex分页组件,可以复用。样式如下,左右各有一组”<<”和”<”,分别表示跳到第一页和前一页(相对应的,跳到最后一页和后一页),屏幕上页面数字只会显示7个,功能很基本。

fy

fy2

fy3

这套组件主要是用到了LinkButton和Repeater。

<!-- page -->
<mx:HBox id="paginationbox" width="100%" height="24"
		 verticalAlign="middle" horizontalGap="0"
		 visible="false">
	<mx:Label text="PAGES: "/>
	<mx:Spacer width="3"/>
	<mx:LinkButton label="&lt;&lt;"
				   styleName="pageLinkBtn"
				   enabled="{_curr_page_index!=0}"
				   click="showImagesInList()"/>
	<mx:LinkButton label="&lt;"
				   styleName="pageLinkBtn"
				   enabled="{_curr_page_index &gt; 0}"
				   click="showImagesInList(_curr_page_index-1)"/>
	<mx:Repeater id="prepeater"
				 dataProvider="{_pages}"
				 count="7"
				 startingIndex="{(_curr_page_index-3 &lt; 0)?0:(_curr_page_index-3)}">
		<mx:LinkButton label="{(prepeater.currentIndex+1).toString()}"
					   enabled="{int(prepeater.currentIndex) != _curr_page_index}"
					   styleName="pageLinkBtn"
					   click="showImagesInList(event.currentTarget.repeaterIndex)"/>
	</mx:Repeater>
	<mx:LinkButton label="&gt;"
				   enabled="{_curr_page_index &lt; _pages.length-1}"
				   click="showImagesInList(_curr_page_index+1)"
				   styleName="pageLinkBtn"/>
	<mx:LinkButton label="&gt;&gt;"
				   enabled="{_curr_page_index != _pages.length-1}"
				   click="showImagesInList(_pages.length-1)"
				   styleName="pageLinkBtn"/>
</mx:HBox>

style比较简单

.pageLinkBtn
{
	paddingLeft:0;
	paddingRight:0;
	paddingTop:0;
	paddingBottom:0;
}

RELATED POSTS

Leave a Reply