Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 08-11-2012, 06:12 PM   #1
clopex
Registered User
 
Join Date: Aug 2012
Posts: 3
Default Pagination Math Help

Hi,

I am using Flex 4.6 and am basically building a gallery with produces a certain number of pages which I have already figured out. The gallery needs a pagination component and I need some help on the math.

I want to display a max of 10 grey dots below the gallery which represents the pagination. When the user goes through the gallery's pages, the dot representing that chunk of pages would turn white. I say chunk of pages because since there are only 10 dots, if there were 100 pages, then each dot would contain 10 pages. For example, on page 1, dot 1 would be white, then when you got to page 11, dot 2 would then be white.

The problem I am having is figuring out the math for when there is something like 36 pages.

private var drawListViewableArea:Number = drawResultsList.width; //320
private var drawListNumPages:Number = drawData.length; //let's say 36
private var numDots:Number = 0;
private var maxNumDots:Number = 10;

//if we have 10 or less pages then just show that many dots
if(drawListNumPages <= maxNumDots)
{
numDots = drawListNumPages;
}
//else, if more, only show 10 dots b/c that is our max that I want
else
{
numDots = maxNumDots;

//****PROBLEM
drawListNumPagesPerDot = drawListNumPages/numDots;
}


The part marked ****PROBLEM.
This equals 3.6, I need to round it because I can't have 3.6 on a dot that just won't work, but rounding up (4) or down (3) will not give me 10 dots. If 4 per dot, the data would only be stored on up to 9 dots. If 3 per dot, then that is even less dots.

Help is appreciated.

Thanks!
clopex is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:34 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.