Tag Archives: text Number

Returning a value to a specific decimol point in AS3

Making games, we often use Number variables to store information. However, displaying these can be tricky, as the Textfield may only have space for a certain amount of characters. In scenarios such as this, it is useful to use the toFixed() method on variable to return a value to the correct decimol point. For instance:


var textField:TextField = new TextField();

var num:Number = 0.12341344525234523523453;

textField.text = num.toFixed(2);

The code above would change to value of the textField variable to 0.12. This is because the toFixed() method returns the number but only to the decimol point index specified in the parameters.