Groups | Blog | Home
all groups > flash actionscript > may 2004 >

flash actionscript : loadmovie random


yevri
5/3/2004 11:54:00 PM
Hi,

I have a movie where I want to load 5 other movies into level 1 randomly. I
have accomplished this with this script in the second to last frame of each
movie:

random = Number(random(5))+1;
loadMovieNum("q_" + random + ".swf", 1);

But I would rather that the movies come in randomly wthout repeating the same
one until all movies have played once. Do I create an array? Will I have a
script at the end of each movie that calls the script in level 0 that has
already determined the order? And after it's already played each movie, have it
randomize them again?

Any advice?

Thanks,
Yevri
yevri
5/5/2004 12:08:02 PM
I guess my first reply didn't get posted - that's why the delay.

Thanks for the advice. I think the script from Kglad is too far over my head.
Is there a simpler way to go about accomplishing this? Essentially what I need
is a way to tell the current script not to include the current movie when doing
the random number.
random = Number(random(5))+1;
loadMovieNum("q_" + random + ".swf", 1);

So if the current swf is q_3.swf, then the script should not include 3 when
choosing from the random numbers. Is there a way to put the number of the
current swf into a variable, have the script read that variable and exclude
that number from the results of the random?

Thanks,
Yevri
rlc5611
5/5/2004 3:11:50 PM
You don't really need to understand it to use it. I cannot think there could
possibly be a simpler way. The script generates an array of numbers distributed
randomly with no repetition. All you need to do to modify that script is
determine how many numbers you want in the array and, to do that, all you have
to do is change the number that is currently where it says ivar<10 to ivar<x
where x is the number of your swf's - 1. So if you have 5 swf's, you would make
that number 4 (arrays are zero-indexed). When you are ready to load a movie,
just grab the next element of the array for the number of the swf to play.
Where you have "random" in your loadmovie statement, replace that with the
current array element.
AddThis Social Bookmark Button