A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Random number generator?? i need help.

  1. #1
    Junior Member
    Join Date
    Mar 2006
    Posts
    15

    Random number generator?? i need help.

    Hello to all who reads,

    I need help creating a random number generator. Its been awhile since using flash and I really need some help. So I'll try and explain what is needed:

    Ok,
    Starting from 1 to 60
    When you click on a button (generate) It will randomly pick six numbers and put them six numbers in 6 empty boxes.

    And a input box for the quantity wanted and maybe a reset button:
    Here is an example pic: hopefully you can see it. Its also at:
    http://ccpropertys.com/gererator.html



    when click the generate button after filling in the quantity box you get 6 of that quantity. if qty 1 you get one line of 6. If the qty is 3 you get 3 lines of 6. Hopefuly you can under stand this?
    Example:

    Generate (button) Quantity 1 (input box)
    you get:
    7 22 34 28 9 54 (each in its own box)
    or
    Generate (button) Quantity 3 (input box)
    you get:
    2 3 28 17 19 49 (each in its own box)
    6 53 42 2 34 8 (each in its own box)
    17 19 23 31 46 51 (each in its own box)

    Thank You,
    Michael
    Last edited by mcarr1973; 02-04-2007 at 04:36 PM. Reason: added content

  2. #2
    Senior Member
    Join Date
    Aug 2004
    Location
    plymouth-uk
    Posts
    313
    This should work.

    var randomNum:Number;
    numArray = new Array();

    var qty:Number=3;/// this is the qty number that can be scripted to use an input box

    for(var i=1; i<=qty;i++){
    numArray[i]= new Array();

    for(var t=1;t<=6;t++){
    numArray[i][t]=Math.floor(random(59)+1);

    trace("["+i+"]"+ numArray[i][t]);
    // just displays the six rand numbers for each qty
    }
    }
    :-)
    NOW! look whats happened! I told you to watch this space and now its gone.

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