A Flash Developer Resource Site

1. Display percentage?

I bet the answer lies within the preloaders and I could study them to reach it, but to cut a corner.

If I want to display the percentage, by calculating it, e.g.:
65 / 250 gives the result 0.264 and means that 65 is 26.4 percent of 250

But how do I make my flashmovie display only 26 ? Or even in som cases there would be more decimals and I could be satisfied with the display of 2 like this 0.26 - buit not more, how is that possible?

2. Math.round(number) ??

3. That would turn 26.4 into 26 surely, but how to turn 0.264 into 26?

EDIT* wait a minute ( times 100 and Math.round(number) )would do it! Solved!

4. Code:
```//n = number;
//m = numbers after the decimal point;
Math.roundN = function (n,m) {
return Math.round((n*Math.pow(10,m)))/Math.pow(10,m)
}
//example
my_num = Math.roundN((1.12345), 2);```

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap