A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: random events

  1. #1
    Relaxing tmoore935's Avatar
    Join Date
    Oct 2001
    Location
    colorado, usa
    Posts
    1,713
    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.

  2. #2
    Senior Member
    Join Date
    Jun 2000
    Posts
    3,512
    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.

  3. #3
    Senior Member
    Join Date
    Jul 2000
    Posts
    5,087
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center