Skip to main content
Participant
September 13, 2006
Question

Setting up a "random" scenario, but with exceptions...?

  • September 13, 2006
  • 1 reply
  • 169 views
I've got a Flash file that, when I press a button, sets a movie clip to jump to a particular random frame using the following code:

gotoAndStop(random(52));

which all works fine. Every time I press the button I get taken to a random frame, as expected.

But what I want to do is for every time one of these random frames is landed on, I want that frame to be "ticked off" so that the NEXT random frame it lands on will NOT be that one. I want this to happen with EVERY press of the button, so that no frame can be landed on twice at any point.
Then when I have eventually pressed the button 52 times, and therefore landed on ALL the frames, I want the whole thing to be re-set. I can do this second part by setting up a counter, and incrementing it each time the button is pressed, and then re-setting it when "presses == 52" etc.
It's the first part I'm having trouble with -- how do I set up my file so that each frame that gets landed on gets "ticked off" so it is now excluded from the randomness of it all?

Any help anyone...?

Thanks!
This topic has been closed for replies.

1 reply

Known Participant
September 13, 2006
This Should work. I didn't implement the counter, I'm sure you know how to do that.
All you need is an array to keep track of which frames have been played.
Keep in mind that you need to use a counter to make sure that the function randomJump doesn't get called when there are no frames left.