Question
Help with Random Image Generator
Summary: I made a flash movie with a 'container' that will
randomly load images that I've uploaded on my webspace. The images
are named "image1.jpg" and "image1blur.jpg" and so forth (the blur
files are used for smooth transitions.
So in the first frame of my movie, I define the maximum number of images:
------------------------------------
imageframes = 86;
rand = Math.floor(Math.random() * imageframes) + 1;
it = rand;
------------------------------------
Sure enough, the first image that's loaded into the container is a random image from #1 to #86, but after that, the image is simply incremented, whereas I want a random image to be loaded every time. Would someone please take a look at my actionscript and tell me how I can go about doing this?
Here's the code from the second frame:
------------------------------------
it += 1;
if (_root.maxpics == undefined) {
_root.maxpics = imageframes;
}
if (it > _root.maxpics) {
it -= 1;
d = 1;
while (d < it) {
swapname2 = eval(("swap" + d));
swapname2.removeMovieClip();
d++;
}
swapname3 = eval(("swap" + it));
swapname3.swapDepths(depths);
it = 1;
}
this.attachMovie("swapx", ("swap" + it), it);
swapname = eval(("swap" + it));
swapname.image = (" http://users.tpg.com.au/gbae/image" + it) + ".jpg";
swapname.imageblur = (" http://users.tpg.com.au/gbae/image" + it) + "blur.jpg";
------------------------------------
My flash file can be found at http://users.tpg.com.au/gbae/Xanga Logo.fla
Thanks in advance for any help you can offer.
So in the first frame of my movie, I define the maximum number of images:
------------------------------------
imageframes = 86;
rand = Math.floor(Math.random() * imageframes) + 1;
it = rand;
------------------------------------
Sure enough, the first image that's loaded into the container is a random image from #1 to #86, but after that, the image is simply incremented, whereas I want a random image to be loaded every time. Would someone please take a look at my actionscript and tell me how I can go about doing this?
Here's the code from the second frame:
------------------------------------
it += 1;
if (_root.maxpics == undefined) {
_root.maxpics = imageframes;
}
if (it > _root.maxpics) {
it -= 1;
d = 1;
while (d < it) {
swapname2 = eval(("swap" + d));
swapname2.removeMovieClip();
d++;
}
swapname3 = eval(("swap" + it));
swapname3.swapDepths(depths);
it = 1;
}
this.attachMovie("swapx", ("swap" + it), it);
swapname = eval(("swap" + it));
swapname.image = (" http://users.tpg.com.au/gbae/image" + it) + ".jpg";
swapname.imageblur = (" http://users.tpg.com.au/gbae/image" + it) + "blur.jpg";
------------------------------------
My flash file can be found at http://users.tpg.com.au/gbae/Xanga Logo.fla
Thanks in advance for any help you can offer.
