That is exactly what I was looking for. Thank you very much, Ken.

Matt 
--- In [email protected], "Kenneth Sutherland" 
<kenneth.sutherl...@...> wrote:
>
> Not sure I'm getting 100% what you're doing but hopefully this will help
> you.
> 
> For page X you would do:
> 
> Min index = ( X - 1 ) * number of records per page
> 
> Max index = Min + (number of records per page - 1)
> 
> So page 1 gives you:
> 
> Min index is ->(1 - 1) * 4 = 0;
> 
> Max index is -> 0 + (4 - 1 ) = 3;
> 
>  
> 
> Page 4 gives you:
> 
> Min index is ->(4 - 1) * 4 = 12;
> 
> Max index is -> 12 + (4 - 1 ) = 15;
> 
>  
> 
> To get a page number from an index do this:
> 
> Math.floor(Index / number of index per page) + 1;
> 
> So index 3 gives you Math.floor(3 / 4) + 1 = 1;
> 
>  
> 
> So index 14 gives you Math.floor(14 / 4) + 1 = 4;
> 
>  
> 
> (your example below had 5 records per page not 4 as you had typed)
> 
>  
> 
> HTH Kenneth.
> 
>  
> 
>  
> 
> From: [email protected] [mailto:[email protected]] On
> Behalf Of fumeng5
> Sent: 29 May 2009 15:59
> To: [email protected]
> Subject: [flexcoders] Need help writing alorithm
> 
>  
> 
> 
> 
> 
> 
> 
> Hi,
> 
> I'm looking for help writing an algorithm in a filter function I am
> using. Here's the situation: Based on a page number and a number of
> records per page, I want to return all indexes that fall within a
> certain range. There are 4 records per page. 
> 
> For example;
> 
> - page 1 will return indexes 0-4
> - page 2 will return indexes 5 - 9
> - page 3 will return indexes 10 - 14
> ....etc, etc...
> 
> So, here are the vars:
> 
> var index:int = myCollection.getItemIndex( item );
> var recordsPerPage:int = 4;
> 
> It's embarrassing, but this is what I have so far....
> 
> if( page <= index < (page * page + recordsPerPage) )
> return true
> 
> Can anyone offer some helpful insight, please? 
> 
> Thank you for any help. 
> 
> 
> 
> 
> 
> 
> Disclaimer 
> -------------------------------------------------------------------------------------------
> This electronic message contains information which may be privileged and 
> confidential. The information is intended to be for the use of the 
> individual(s) or entity named above. If you are not the intended recipient, 
> be aware that any disclosure, copying, distribution or use of the contents of 
> this information is prohibited. If you have received this electronic message 
> in error, please notify us by telephone on 0131 476 6000 and delete the 
> material from your computer. 
> Registered in Scotland number: SC 172507. 
> Registered office address: Quay House 142 Commercial Street Edinburgh EH6 
> 6LB. 
> 
> This email message has been scanned for viruses by Mimecast.
> -------------------------------------------------------------------------------------------
>


Reply via email to