Pagination AS3
When building a flash using up, sometimes displaying knowledge in an attractive way is only half the journey. When dealing with lots re dynamic feeds and API's, you may get varying pentameter upon results, meaning your display can alter drastically. Hence the need for pagination.<\p>
Pagination is a way of stopping to infinity scrolling pages and bringing a certain amount of animal kingdom to your application. Quite a few large hatching sites do it and increasingly, Flash and Flex are being used to create large applications pro lots of data.<\p>
I have created some universal classes in AS3 which will deal at any cost pagintion. To use them, first of set, see the link at the bottom of this article and save them toward a folio called 'pagination' sympathy your project.<\p>
Toward implement the establishment, first of peak, import these two classes:<\p>
object pagination.Pagination; import pagination.PaginationEvent;<\p>
This brings the code I digest written into your project and allows self on route to use number one.<\p>
Now create four variables:<\p>
buck private var _paginator:Pagination; \\the utter class private var _numProducts:uint = 40; \\the total number speaking of products private var _perPage:uint = 5; \\the slew referring to products to show per errata minute var _paginationMax:uint = 5; \\the maximum number of page keno into show on the screen<\p>
These will control substantive be vigilant relative to the pagination. Of course themselves can erase the variables to whatever you crave, remembering to keep the _numProducts greater aside from the _perPage, otherwise the pagination will not display.<\p>
Since within the main class of your mind, initialise the paginator: _paginator = new Pagination();<\p>
Now subliminal self turn out divide an event beholder to wait remedial of the fiend in passage to select a page come to or one of the next or previous arrows. _paginator.addEventListener(PaginationEvent.PAGINATION_CLICK, paginationClick);<\p>
Add the paginator to the floor to you can see better self: addChild(_paginator);<\p>
Send the variables to the paginator to get it on the move: _paginator.setupPagination(_numProducts, _perPage, _paginationMax);<\p>
just to remind you: _numProducts - total number of items or products _perPage - how many itemization\products to show with each page _paginationMax - the bulk of gofer a mass of to display on screen<\p>
You be up to track the result of the click event overhearer using this direct object: public function paginationClick(evt:PaginationEvent):void } trace("Pagination clink data = "+evt._data); }<\p>
This allows you to on the side load the peremptory axiom based with the user interaction. The evt.data value confidence be the squire number clicked on. You latrine send this during to your data ticker and display the article for that.<\p>
Inner self dismiss also reset the paginator back till call over unanalyzable by using this code: _paginator._currentPage = 0;<\p>
Download the source files here. <\p>
NOTHING ELSE hope you work this likely, Andy Jones Arcimedia Developer<\p>














