Number.toFixed()

var someValue:Number = 2.0480531167374427;

// want to show only 3 decimal places?
trace(someValue.toFixed(3)); // outputs 2.048

An easy way to get rid of extra decimal values. This is useful when you want to show decimal values in text fields. I only recently noticed this in the docs, I used to do this type of thing:

trace(int(someValue * 1000) / 1000);  // outputs 2.048

4 comments

  1. yeah. They should at least have an option to download the help locally…. maybe they do…. I heard about the help being browser only before it was released and I really hoped that they would change it…. too bad they didn’t.

Leave a Reply

Your email address will not be published. Required fields are marked *