I’m using a piece of randomizing code for loading jpegs into a movie, and I wanted to change the math function so that on loading the window a random file is loaded, and then each successive button click loads the next file in sequence. For example, when the window opens a random function decides that 03.jpg will be shown, then when a button is clicked it loads 04.jpg, then 05.jpg etcetera.
The code I am using so far is:
filename = [“01.jpg”, “02.jpg”, “03.jpg”, “04.jpg”, “05.jpg”, “06.jpg”, “07.jpg”, “08.jpg”, “09.jpg”];
path = “pictures/topleft/”;
i = filename.length;
k = Math.floor(Math.random()*i);
loadMovie(path+filename[k], topleftloader);
However this results in a lot of repetition. Oftentimes a reload brings up the same image.
Any advice would be much appreciated!
Thanks.