PDA

View Full Version : Just A Simple Random As



Dominerd
August 31st, 2004, 02:19 PM
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?

lunatic
August 31st, 2004, 02:37 PM
search Random, Random Number, and/or Random Frame in the forums. I think this has been answered before.

:hr:

Dominerd
August 31st, 2004, 03:00 PM
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.

lunatic
August 31st, 2004, 03:12 PM
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:

stringy
August 31st, 2004, 03:14 PM
I tried it and nothing I was looking for poped up.
v = Math.ceil(Math.random()*2);
mc.gotoAndStop(v);

lunatic
August 31st, 2004, 03:17 PM
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:

stringy
August 31st, 2004, 04:07 PM
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()