How do I make a random number that corresponds to the frame I want to go to?(I'm using Flash MX)
Printable View
How do I make a random number that corresponds to the frame I want to go to?(I'm using Flash MX)
Let's say you want to choose between frames 10,37,47 and 100.
code:
choices = [10,37,47,100];
frameNumber = choices [ random(choices .length) ];
gotoAndPlay(frameNumber);
For flexibility, you can also (and probably should) do it with frame labels.
code:
choices = ['john','paul','george','ringo'];
frameNumber = choices [ random(choices .length) ];
gotoAndPlay(frameNumber);
If the frames are sequential, say 1-10, you can do it this way:
code:
gotoAndPlay( random(10)+1 );
Finally, if anyone posts code to this thread suggesting the use of Math.round() in conjunction with Math.random(), they are seriously deluded. I've posted numerous times about this subject in prior threads. Look it up.
When I publish it says there's an error and that statement must appear in on handler. What does that mean?
Nevermind I got it.
I want to do somethng similar to this and have become a bit stuck. What I want to do is have 10 or so images that can be used on a homepage randomly. Using the previous methods i have managed to get the .swf to randomly scroll through the images before choosing one. I dont want it to scroll though, I want i to choose one straight away. Is there a way of doing this?
To see what i have done so far visit www.suggymoto.com/main.html
Thanks