Pagination Math Help
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
numDots = maxNumDots;
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.