Hi,
got the following question for you guys :
var testArray:Array = new Array(“mc0”,“mc1”,“mc2”,“mc3”,“mc4”,“mc5”,“mc6”,“mc7”,…);
var page:int = 1
var itemsPerPage:int = 2
function PageSelect(page:int, itemsPerPage:int){
}
i need to find out how i can select items from the array considering the 2 vars that are given.
in this example the function PageSelect(1,2) should return mc2 & mc3
page = 1 & itemsPerPage = 2
page 0 = mc0 & mc1
page 1 = mc2 & mc3
page 2 = mc4 & mc5
page 3 = …
…
in case page = 2 and itemsPerPage = 3
page 0 = mc0 & mc1 & mc2
page 1 = mc3 & mc4 & mc5
page 2 = mc6 & mc7 & mc8
im trying to write a function which accepts those 2 variables and returns the correct mc’s from the array.
really hope someone can give me a hint in the good direction. Tried using the array.slice method but i didnt manage to get the correct results or partially correct results.
im sorry if this is not very clear, but im not a native english speaker/writer, so it’s not easy to explain. My appologies for that !
thanks again !
Ariff
i searched a bit more and found the following solution :
if i would slice the array like this :
array.slice(pagerecordsPerPage, (pagerecordsPerPage) + recordsPerPage)
i think that would give me the correct solution