I need to implement a for loop to generate an image animation. As shown in the attached imagehttp://i.stack.imgur.com/VCjKW.jpg[^] , if a user selects hbox=6 and vbox=4, an a 2-d array of 24 items will be created. Now we need to access these elements as follows:

1st iteration: [1][1]2nd iteration: [2][1], [1][2]3rd: [3][1],[2][2],[1][3]4th: [4][1],[3][2],[2][3],[1][4]5th: [4][2],[3][3],[2][4],[1][5]and so on until the last iteration is [4][6]

So please provide me a for loop implementation to access the elements in such fashion.

But if 5th iteration i do not clear the varying part. There i saw row no is still same for iteration 4 and iteration 5. This requirement is little confused me. let me know the code will help you or not.