Hi

How do I walk through my array

I need to allways skip item[0], eg. [1] is allways the start
Now I need to run through array 1 to 6
When I reach 6 I need to stop
Next time I need to start at 7 and run through 6 more
If the I reach the array length in an iteration I need to start at 1 again. I almost managed to figure that out, but I also need to do this backwards and I am looking blind at my code now, so If any kind and inteligent person out there can help me I would appricate it so much

Here is my code so far:


start = 1; //We start at 1
end = 6; // And end at 3

noToDisplay = 6; // We always wants to display 3

//Create our array
foo = new Array();
foo[0] = "aa"; //Index 0 we don't need, but it must be there

foo[1] = "1b first";
foo[2] = "2c";
foo[3] = "3d";
foo[4] = "4e";
foo[5] = "5f";
foo[6] = "6g";
foo[7] = "7h";
foo[8] = "8i last";

items = foo.length -1; //Since we don't need index 0 we don't count it.

//Attach function to our buttons
//Go forward in the array
//
buttonForward.onRelease=function() {
h=0;
for (var i=start; i<=end; i++) {
h++;
//Since we allways want to output 3 we need to start at 1 again if we reach our length
if (i > items) {
i = 1;
end = i+noToDisplay-h;
}

trace(" "+ foo[i]);
}
trace("~~~");
start = i;
end = i+noToDisplay-1;
}

buttonBack.onRelease=function() {
h=0;
end = end-(noToDisplay*2);

for (var i=start-(noToDisplay*2); i<=end ; i++) {
h++;
if (i == 1) {
trace("y")
i = items-noToDisplay-h;
end = i+noToDisplay-1;
}
trace(""+ foo[i]);
}
trace("~~~");
start = i;
end = i-noToDisplay-1;
}