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 4 Rounding UP to Natural numbers.

To complete this tutorial you should have completed the

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=> Ceil and double click to move the script to the value box. Ceil stands for ceiling and causes the script to round whatever is in the brackets UP 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 Up (ceil or ceiling) it will always be 1. 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 *12. Your final script should appear as follows.

randomnumber = Math.ceiling(Math.random()*12);

6. Your script will now give you numbers from 1 to 12.

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

The Next Tutorial will teach you how to get a random a group or set of sequential numbers, not necessarily starting at 0.



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