Developing Webs logo
Google
Web DW-Main DW-Photoshop
Visit the message board for solutions or post a question Check out the Classes offered for free at Developing Webs Voice Chat submit a tutorial, resources, article, font for publication consideration and earn a one way link back to your site Get more specifics about the Developing Webs Voice chat room and its room members View the current news at Developing Webs alternative sites which are resources for your d3evelopment needs Join Developing Webs Chat Link to us on your web page to help support this resource! Check out Developing Webs At yahoo groups! Developing Webs Home Adobe Photoshop Tutorials Macromedia Flash Tutorials Jasc Paint Shop Pro Tutorials Adobe Illustrator Animation basics Some Basic PHP tutorials Perl Tutorials HTML Tutorials Cascading Style Sheets javascript Front Page Tutorials Macromedia Dream Weaver Tutorials dreamweaver Publishing your site, FTP, ChMod, Promotions Tools to help you create your site Free and shareware fonts to download Photographs to use in your projects Shop for your site needs Free Online classes REcommend this site to others Log in or edit your information when logged in Developingwebs Log Out Change My Account details and preferences
RSS Newsfeed
for your site
DW News
Calendar
DW Forum
Right click on button and copy shortcut

Add to My Yahoo!

Reminder
Remember to book mark this site!



Request a Tutorial

Generating Random Numbers 2 Setting ranges of numbers above 0.

You should have completed the Generating Random Numbers 1 to complete this.

1. Open your movie. Your script in frame 1 of your actions layer should look like this: 

randomnumber = Math.random();
 

Test your movie. You will see a random number generated every 5 seconds. Notice that the random number is between 0 and 1. This is always what this script produces.

2. Go back to your movie timeline and click in frame 1 of the actions layer. We need to multiply the random number between 0 and 1 by 10 to make the number be between 0 and 10.  Add to the line a multiplier,  for the value *10 to multiply by 10 so that your script now looks like this:

randomnumber = Math.random()*10

Test your movie. Every 5 seconds you will get a random number between 0 and 10. The long decimal that is cut off is what makes this number a real number. The next tutorial will deal with rounding real numbers to whole numbers.

3. To get a random number between 0 and 100, set the multiplier to 100 and test your movie.

randomnumber = Math.random()*100

4. To get a random number between 0 and 25, set the multiplier to 25,

randomnumber = Math.random()*25

Random Multiplier Chart:

Generate between multiply by
0 - 1  
0-10 10
0-12 12
0-20 20
0-25 25
0-100 100
 

5. Now that you have seen how to get random numbers between 0 and any number, the next lesson will teach you how to make the real (decimal) number into a whole number, without numbers to the right of the decimal

The next tutorial teaches you how to round the numbers down to whole numbers.



"Building The Web Into a Nicer Place -- One Site At A Time"
Developing Webs Group Copyright © 2001-2012 All Rights Reserved
Privacy and Legal




iSECURE Network Security