Just A Simple Random As

I need to find an action script that tells a random movie clip scene to play… You see I have a movie clip with two frames ( each with “stop” in the AS), but when I export the film, I want it to randomly pick which of the two frame to show…

Could anyone help me out?

search Random, Random Number, and/or Random Frame in the forums. I think this has been answered before.

:hr:

I tried it and nothing I was looking for poped up.

set a variable to a random number. Do some research on how to make a random integer because the random function in flash generates a random number between 0 and 1 so you have to do some multiplying (to get the number to be between 1 and 2) and some rounding (using either floor or ceiling to get it to be exactly 1 or exactly 2).

Then its just a matter of setting the gotoAndPlay(yourrandomvariable).

:hr:

v = Math.ceil(Math.random()*2);
mc.gotoAndStop(v);

Actually I did some searching of my own and its even simpler that that!

Try this:


num=random(2)+1;
trace(num)

you’ll only get 1 or 2 every time.

:hr:

Yeh i use random() too but it is deprecated and we should really be using Math.random()