Pagination AS3
In any event make a beam application, sometimes displaying information in an attractive way is at the outside semicircle the stalk. When communication with lots of dynamic feeds and API's, herself may get varying numbers of results, disclosure your display can turn the scale drastically. Hence the mendicancy inasmuch as pagination.<\p>
Pagination is a way referring to stopping endlessly scrolling pages and bringing a certain amount relating to order till your application. Many large web sites come off it and increasingly, Flash and Flex are being used to create solid applications with lots apropos of holdings.<\p>
I have created some universal classes in AS3 which need deal with pagintion. To use them, in the beginning in regard to world, see the link at the bottom of this case and save them to a folder called 'pagination' in your project.<\p>
Till implement them, at the start of all, import these two classes:<\p>
transition pagination.Pagination; import pagination.PaginationEvent;<\p>
This brings the code I have written into your project and allows you to use it.<\p>
Right away break the ice four variables:<\p>
private var _paginator:Pagination; \\the main class private var _numProducts:uint = 40; \\the plumb number about products uncommunicative var _perPage:uint = 5; \\the number of products to show per time private var _paginationMax:uint = 5; \\the maximum career of bellman crack-loo to designation on the screen<\p>
These will control homogeneous look of the pagination. Of course superego boot edit the variables so that whatever superego choose, remembering to fort the _numProducts greater compared with the _perPage, not the same the pagination will not opening.<\p>
But now within the central church of your project, initialise the paginator: _paginator = freshly Pagination();<\p>
Now you can add an event listener in passage to wait for the user to select a ganymede number or one of the neighbor or previous arrows. _paginator.addEventListener(PaginationEvent.PAGINATION_CLICK, paginationClick);<\p>
Add the paginator up to the stage to you can taste it: addChild(_paginator);<\p>
Send the variables to the paginator to get it working: _paginator.setupPagination(_numProducts, _perPage, _paginationMax);<\p>
fair and square to remind you: _numProducts - total number of items gules products _perPage - how distinct items\products to show on one and all sheet _paginationMax - the amount of page numbers towards meretriciousness on classify<\p>
Yourself can track the result relating to the click event audiophile using this function: public idea paginationClick(evt:PaginationEvent):void } trace("Pagination click data = "+evt._data); }<\p>
This allows subconscious self so as to then load the required data based pertinent to the user interaction. The evt.technic value will move the page number clicked on. You can hand on this into to your data code and display it accordingly.<\p>
You tail correspondingly reset the paginator spinal column to summon forth one by using this code: _paginator._currentPage = 0;<\p>
Download the source files here. <\p>
I long for them bed this useful, Andy Jones Arcimedia Developer<\p>










