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

Comparing Rounding Actions

1. Open your file. Notice there are three layers. The bottom layer contains your text boxes. the middle layer has the text names for each text box. The top layer is for actions. Click in the first frame of the actions layer and open the actions panel.

2. Creating our Random number: Click actions=> variables=> Set variable (double click).

Name the variable randomnumber. Click in the value field. Click objects=> core=> Math=> Methods=> Double click random. The script Math.random() will appear in the blank.

Since this number will be a number between 0 and 1, we must use a multiplier to make it larger then 1, so add * 10 which will multiply it by 10. Check expression so the script will be interpreted by the server, instead of literal. The resulting script in the actionsript window looks like this:

randomnumber = Math.random() * 10;

 

3. Round our random generated number UP. Click on the script line in the main action script area. Click actions=> variables => Set variables (double click). Set this variable to randomceil by typing it in the variable parameter. Click in the value field. Click objects=> core=> Math=> Methods=> Double click ceil. The script Math.ceil() will appear in the blank. We want out random generated number to be rounded using this  Math.ceil command, so we can't generate a new one or we will be rounding a new one. We place the name of the variable which is equal the current random number in the parentheses; type in randomnumber inside the parentheses. Check expression. The resulting script looks like this:

randomceil = Math.ceil(randomnumber);


4. Round our random generated number DOWN. Click on the last line of the script line in the main action script area. Click actions=> variables => Set variables (double click). Set this variable to randomfloor by typing it in the variable parameter. Click in the value field. Click objects=> core=> Math=> Methods=> Double click floor. The script Math.floor() will appear in the blank. We want our random generated number to be rounded using this  Math.floor command. Type in randomnumber inside the parentheses. Check expression. The resulting script looks like this:

randomfloor = Math.floor(randomnumber);

4. Round our random generated number "Round". Click on the last line of the script line in the main action script area. Click actions=> variables => Set variables (double click). Set this variable to randomround by typing it in the variable parameter. Click in the value field. Click objects=> core=> Math=> Methods=> Double click round. The script Math.random() will appear in the blank. We want our random generated number to be rounded using this Math.random command. Type in randomnumber inside the parentheses. Check expression. The resulting script looks like this:

randomround = Math.round(randomnumber);

There are now 4 lines of script in the action panel now. We can lock the action panel Unlock the textbox layer. Use your arrow tool to click on the top box to highlight. Set the Var to  randomnumber.

Highlight the next text box. Set the var to candomceil.

Highlight the 3rd dynamic text box, and set the var to our 3rd variable, randomfloor.

Highlight the last dynamic text box and set the var to randomround.

 



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