A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [F8] Random not so random..?

  1. #1
    Senior Member
    Join Date
    Nov 2006
    Posts
    162

    [F8] Random not so random..?

    Hi guys!

    I am creating a random introduction page, which have 6 different frames and each time you load the page a random frame is supposed to appear.

    I use this code: gotoAndStop(random(6)); on the first frame of timeline.

    But then, it seems to only get the first 3 frames, on 30 refreshs I havent seen once frame 4-5-6....

    Is there a better way to build randomness?
    Any help appreciated
    Thanks!

  2. #2
    Busy doing nothing Boris the Frog's Avatar
    Join Date
    Jan 2001
    Location
    Derby, UK
    Posts
    305

    Help

    stop();
    function getRandomNum(max, min):Number{
    var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
    return randomNum;
    }

    btn_move.onRelease = function(){
    gotoAndStop(getRandomNum(6, 1));
    }

    I have attached a fla below if that helps to explain further
    Attached Files Attached Files
    --------------------------------------------------
    ‘There is no emoticon to express how I am feeling’ - Comic Book Guy
    There's an effective, simple solution to carbon sequestration... it's called 'coal', so leave it alone!
    There's an effective, simple solution to carbon capture....it's called 'trees', so plant some!

  3. #3
    Senior Member
    Join Date
    Nov 2006
    Posts
    162
    Thank you for your help, I dont want to offend you but I just downloaded your file on my MAC, and my computer totally crashed after, and now there is nothing to do with it, I dont know if it is your file or not, but maybe just check if it is not infected or something, it may not be this, but something happened really weird, so just making sure it does not happen to someone else after......
    I will try your code when I fix my computer..
    Thanks

  4. #4
    Senior Member
    Join Date
    Nov 2006
    Posts
    162
    Ok nevermind, your file is fine, sorry for this!....

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