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
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 3 Rounding down to whole numbers.

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

1. Open your source movie from the last tutorial. Click on Frame 1 of the actions layer. On the action panel you will see the script and the parameters for the script. Erase the value field.

2. With your cursor in the value box, click through the action toolbox from objects=> core=> Math=> Method=> Floor and double click to move the script to the value box. This will round whatever is in the brackets down to the nearest whole number.

3. Click inside the brackets inside the value line. Find the random on the left action toolbox by Objects=> Core=> Math=> Methods=> Random and double click to move the script inside the bracket in the value line.

4. If we tested the script now, random numbers generated now will be between 0 and 1, so when they are rounded down (floor) it will always be 0. We must add a multiplier.

5. While your cursor is still inside the brackets of the Math.floor() but after the Math.random(), add your multiplier, in this case *100. Your final script should appear as follows.

randomnumber = Math.floor(Math.random()*100);

6. Your script will now give you numbers from 0 to 99.

7. Try using the different multipliers or 5, 10, 17, 25  to get different results.

The Next Tutorial will teach you how to round random numbers up.



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