Okay, after some research, I found that using the array can sometimes slow it down a tad. Let's try to avoid that.
I will continue to do some research, but instead we could just tell Flash to do a random math function and self pic an image from the result.
In order to do this, you will have to change (maybe) a few things. First, create an emptyMovieClip (if you don't know how, just ask) put it on the stage and give it an instance name we will call ours "empty". Next, you will have to give your images numeric names (1.jpg, 2.jpg etc but NOT 0.jpg)
Now all you do is create the function to randomize the number like so:
Code:
MovieClip.prototype.setRand = function() {
largest= 10;//change the number to the total number of images
lowest = 1;//this should stay the same
rand = ((Math.floor(Math.random()*100)%(largest-lowest+1))+lowest);
Then we tell the movie to take that number, and apply it to the file name, along with the folder and ".jpg" to grab the image out of the server with:
Code:
loadMovie("images/"+rand+".jpg", "empty");
Then we just call the function when we need it (right away if you want ~~ probably preferred here) :
So all in all it should look like this:
Code:
MovieClip.prototype.setRand = function() {
largest= 10;
lowest = 1;
rand = ((Math.floor(Math.random()*100)%(largest-lowest+1))+lowest);
loadMovie("images/"+rand+".jpg", "empty");
}
setRand();
Give that a try and see what you get
Bookmarks