# Pagination in action script 2.0

**URL:** <https://forum.kirupa.com/t/pagination-in-action-script-2-0/286273>\
**Category:** flash\
**Created:** [April 13, 2009, 7:07am UTC](https://forum.kirupa.com/t/pagination-in-action-script-2-0/286273 "2009-04-13T07:07:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmad\_babakhel](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@ahmad\_babakhel](https://forum.kirupa.com/u/ahmad_babakhel)\
**Post date:** [April 13, 2009, 7:07am UTC](https://forum.kirupa.com/t/pagination-in-action-script-2-0/286273/1 "2009-04-13T07:07:59Z")

</div>

I am new to action scripting, and want to know that how to paginate the data coming from mysql data base and how to dynamically send one of them back to php page,  
i use the following code for pagination but don’t know how to dynamically send the data back to page by click on the button on the text field.

//the current page we’re on  
var page:Number = 1;  
//the limit of values we need per page  
var limit:Number = 20;  
//the current row that we’re working on  
var row:Number = 0;  
//The total pages that we have  
var totalPages:Number = Math.ceil(values.length/limit);  
//the text at the bottom of the page  
var pageTxt:String = 'Page ‘+page+’ out of '+totalPages;

//the function that will add all of the mc’s to stage  
function createValues():Void{  
//this will always limit the amount to the limit variable  
//but, “i” will act as a marker for which part of the values  
//array that we’re going to use  
for(i=(page-1)_limit;i\<page_limit;i++){  
//checks if there actually is a value where “i” is  
//otherwise we’ll get some undefined movieclips  
if(i \< values.length){  
//attaches the movieclip to the stage  
attachMovie(‘mcValueHolder’, ‘value2’+row, getNextHighestDepth());  
//sets the coordinates based on the row

```
        if(row&gt;9){                    
        _root['value2'+row]._x = 300;
            if(i%10==0){
                var j=35;
                _root['value2'+row]._y = j;
            }else{
                j = j +20;
                _root['value2'+row]._y = j;
            }
        }else
        {
        _root['value2'+row]._x = 15;
        _root['value2'+row]._y = 35+_root['value2'+row]._height*row;
        }

```

// \_root[‘value’+row].\_y = 5+\_root[‘value’+row].\_height_row;  
//sets this guys value to the correct part of the array  
\_root[‘value2’+row].thisValue = values_;

```
        //move onto the next row
        row ++;
    }
}
//then we reset the rows so we can use the variable again
row=0;

```

}  
//we have to remove movieclips from the stage if we’re going to paginate  
function removeValues():Void{  
//its a simple function, hopefully you can understand it  
for(i=0;i\<limit;i++){  
\_root[‘value2’+i].removeMovieClip();  
}  
}  
//adding functions to the buttons when they’re clicked  
mcPrev.onRelease = function(){  
//if the page isn’t too low  
if(page \> 1){  
//then go to the previous page  
removeValues();  
page --;  
createValues();  
//updating the text  
pageTxt = 'Page ‘+page+’ out of '+totalPages;  
}  
}

mcNext.onRelease= function(){  
//if the page isn’t too high  
if(page \< totalPages){  
//then go to the next page  
removeValues();  
page ++;  
createValues();  
//updating the text  
pageTxt = 'Page ‘+page+’ out of '+totalPages;  
}  
}

//we’re going to have to show the values first thing  
createValues();
