A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: use of random command

  1. #1
    Junior Member
    Join Date
    Mar 2001
    hello, can anyone help me.
    I need five movie clips to race each other.
    This is the random part of the script I am
    currently using:

    tellTarget ("_root.run") {
    m1go = random (8)+2;
    m2go = random (8)+2;
    m3go = random (8)+2;
    m4go = random (8)+2;
    m5go = random (8)+2;

    I need each variable m""go to have a different
    value. At the moment that is down to chance.
    Can I do this. Also can I make the values differ
    by fractions rather than whole numbers i.e. 2.5, 1.5, 3?

    Your help will be very, very much appreciated



  2. #2
    Senior Member
    Join Date
    Aug 2000
    That should work... what kind of trouble are you having? To get a fraction you could do this:

    rand = random(100)/10;

    that will give you a number between 0 and 99 and move the decimal over one place so that you have a number between 0 and 9.9 ...
    good luck.

  3. #3
    Senior Member
    Join Date
    Mar 2001
    Flash 5 gives you a method on the Math object:


    That will return a value between 0.0 and 1.0

    You might want to use this instead and multiply up the result until it's near the range that you require.



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