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.

Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditShare on StumbleUponShare on TumblrEmail this to someone

One thought on “Returning a value to a specific decimol point in AS3

  1. your game kinda glitched when my character was entering the battlefield in stage 4 or 5 and 6. None of the spells would work or even the standard attack. I even messed around with it by switching to the menu, and retesting it by re-entering combat and then returning to map. this game had good ideas and graphics… i just hate that i didn’t get to see the full potential.

Leave a Reply

Your email address will not be published.