-
Random numbers?
How do I make a random number that corresponds to the frame I want to go to?(I'm using Flash MX)
-
Senior Member
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.
Last edited by jbum; 10-01-2004 at 05:44 PM.
-
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.
Last edited by Pyte; 10-01-2004 at 06:35 PM.
-
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|