Using Flash'sMathobject, you can round to the nearest whole number using theMath.roundcommand. You may, however, prefer to round to different decimal places. This TechNote offers a technique for rounding to a specified decimal place.
Rounding to the hundredth decimal
Rounding to the nearest decimal simply involves inserting code in the Actions panel, as follows:
||Open your movie in Flash.
||Select a Frame or an Instance.
||Choose Windows > Panels > Actions.
||Add this ActionScript in your Actions Panel to round to the hundredth decimal place, replacing yourNumber with the value you would like to round:
How the code works
The number used in the example below is 20 divided by 7, which equates to 2.857142857142857.
Rounding to other decimal places
If you prefer to round to a decimal other than to the hundredth, you can easily modify the code. Below are examples of code that will round (20/7) to different decimals:
||Number of Decimal Places
For more details on how to round to the nearest integer, please see the online ActionScript entry for Math.round.
math round; object; tn_15542