;

PDA

Click to See Complete Forum and Search --> : random events


tmoore935
06-21-2002, 02:20 PM
Hello,
Is there a way to make a button go to a random frame? I mean when you click the button, one time you go to frame 20. The next time you run the program and click the same button, you go to frame 23, etc.

Bob Hartzell
06-21-2002, 03:20 PM
You can do it using action scripting available in KoolMoves. I will let someone else fill in the blanks or you can investigate simple action scripting commands.

johnie
06-21-2002, 05:21 PM
Math.floor(Math.random()*x)
or
Math.round(Math.random()*x)

The complete script is

x=10
//x is the top value of the random number in this case we are going from 0-10
frame=Math.round(Math.Random()*x)
// Sets VAR frame as a random Number between o and x
GotoAndPlay(frame)
//Goto and Plays the random Frame

This script can go on a button (needs event handlers) or on a Frame.