Page flip problems

Hello there. I have another problem here. I am using this page flip and in the actionscript layer I have a function that builds some borders for some images. This function get a numeric parameter that represents the number of borders to display. My problem is that I want to display only 6 per page and the number of pages to be created dynamic depending on the number of borders. So, for example if I have 22 borders to create I have to create 6+6+6 pages and the last page uith 4. I have build the function my page flip is working the only problem is that I dont know how to put them together.
Thank you in advance.