Professional :: Flash Calculator - How To Get Values With Specific Decimal Places
Mar 6, 2011
I must have done something wrong because when I try this
var a = 5.222+ 0.0002trace (a)
I get // 5.222200000000001
And then I try
var b = 2.222+ 0.0002trace (b)
I get // 2.2222
View 2 Replies
Similar Posts:
Sep 5, 2008
I followed an online tutorial and built an AS3 calculator for Flash. Works great, and I even figured out how to modify the code to add a clear button. The one issue is that, the way this is coded, one can only enter positive integers or zero (i.e. 0, 1, 2, 3...) into the boxes (num1 and num2 in the code below). As in code below (lines 15-16), the tutorial suggests a clever code so that users won't be able to enter anything (e.g. letters) except numbers into the num1 and num2 boxes (restrict = "0-9").
The result is that one cannot enter a decimal place, and also that one cannot enter a negative number. How to modify the code below to allow decimal places and negative numbers to be entered in the num1 and num2 boxes? I suspect that another conflict in the code with this plan could be the "parseInt" statements near the bottom. I have posted the swf FYI at [URL].
ActionScript Code:
plus_btn.addEventListener(MouseEvent.CLICK, plusClick);
minus_btn.addEventListener(MouseEvent.CLICK, minusClick);
times_btn.addEventListener(MouseEvent.CLICK, timesClick);
divide_btn.addEventListener(MouseEvent.CLICK, divideClick);
equal_btn.addEventListener(MouseEvent.CLICK, equClick);
clear_btn.addEventListener(MouseEvent.CLICK, clearClick);
[Code] .....
View 6 Replies
Sep 6, 2000
I have a cost calculator in flash, only the price comes out with about a hundred decimal places... any convenient way to round it up to 2? I was hoping there was some (fairly easy) way to nicely format an output..
View 3 Replies
Jul 9, 2010
I have a simple AS1 script running on a button:
//
on (release) {
a = Number(answer2);
w = Number(withvat);
v = Number(vat2);
answer2 = (w / 117.5 * 100);
vat2 = (w / 117.5 * 100 * 0.175);
}
It works but the results are sometimes many decimal places long. Any way I can make my results round to two decimal places (accurately). So 5.6994 becomes 5.70 etc.
View 21 Replies
Jan 26, 2012
my cost per month textbox typically returns multiple decimal places, is it possible to limit it's output to two decimal places like real monetary calculations?
[Code]...
View 1 Replies
Sep 22, 2010
I want to round up a number calculation with 2 decimals after dot For example:
Code:
var tempCalcul:Number = 100.00 - 90.90;
var temp:Number = int((tempCalcul)*100)/100;
test.text = temp;
test.text is giving me 9.09 when it should give 9.10.
View 5 Replies
Dec 1, 2011
Just made a quick calculator but having trouble understanding how to round to no decimal places. Here is my code:
on (release) {
sum2 = int(sum1) * 5;
sum3 = sum2 / 12;
}
Here is an image of the calculator
View 3 Replies
Jan 3, 2004
Im thinkn' its around but I just cant search it...Sooo....What is the Math.???? for making a number always have 2 decimal places?
View 5 Replies
Aug 27, 2005
how do you set a number to 2 decimal places??
View 7 Replies
Nov 11, 2005
does anyone have or know of a simple sure fire way to round up a figure to 2 decimal places.
flash has a horible habbit of removing 0's.
I need to round up figures but having to split a number like 100.056 (fine when its a string, but not when its a number)
rounding up the 056 gets complicated as flash will see it as 56.
View 3 Replies
Apr 29, 2008
I would like to put in 250.00 as an amount and with all the other calculations I would liek that decimal place to be recognised and then in the final calculation that decimal point is displayed correctly, but it doesnt. If there is a simple reason for this then great, but if you need screen schots, fla the action script
View 1 Replies
Jun 26, 2009
I haven't used actionscript 3.0 in a while and I'm finding myself slightly lost.
I have a fully functional calculator but I need it to return numbers with a max of two decimal places. (x.00)
I'm not sure where to input the code and how to make this work.
here's my code:
total_btn.addEventListener(MouseEvent.CLICK, getTotals);
function getTotals(event:MouseEvent):void
{
[Code].....
View 2 Replies
Feb 15, 2010
How can I tell flash to use only four decimal places when a number is display in a textField?Something like this:2.2356 , 0.2538, 0.2968, 0.0001 etc. Instead of infinitenumbers:.23565985 , 0.2538486
View 4 Replies
May 24, 2010
I haven't used actionscript 3.0 in a while and I'm finding myself slightly lost.I have a fully functional calculator but I need it to return numbers with a max of two decimal places. (x.00)I'm not sure where to input the code and how to make this work
here's my code:
total_btn.addEventListener(MouseEvent.CLICK, getTotals);
function getTotals(event:MouseEvent):void
[code].....
View 1 Replies
Sep 21, 2010
For example I could have 6 or 6.5 or 6.75 or 6.125 but I need to convert all to show zeros at the end if they are less than three decimal places. So it should output respectively,6.0006.5006.750or leave alone at 6.125 or some other three digit number.
View 6 Replies
Sep 12, 2004
How I can format numbers in Flash so that it will show two decimal places regardless of the number itself?
View 7 Replies
Dec 30, 2011
I have been tasked with creating a custom "calculator" for a client that uses a specific equation. The client inputs data into two Input Text fields and the result shows up in a dynamic text field. Is there any way I can limit the number of decimal places to two? Here is my code (which works, except for the decimal issue):i function onCalculate(){one = Number(number_one);two = Number(number_two);result_1 = ((one / 4) * (65 / (1 - 0.25))) + ((two / 0.5) * (65 / (1 - 0.25)));}
View 3 Replies
May 6, 2010
I have a program that adds values together. I need the variable to display with 2 decimal places. Right now $1.50 would look like: 1.5
How do I make Flash display the zero automatically?
View 2 Replies
Sep 13, 2008
I am totally confused about this one. I am trying to display a number as x.xx, but I'm having problems! The number has 0, 1 or 2 decimal places, so I have an if else to add '0' or '.00' on the end if there are 1 or 0 decimal places respectively.[code]...
View 3 Replies
Oct 6, 2009
If I have a variable interestRate and the value is 6.5 What would be the simpest way to display it as 6.50 also if it was just 6 how to display as 6.00
View 3 Replies
Feb 13, 2012
why does this not work for counting the number of decimals?
Code:
var num:Number = 4.321;
counter=0
while (num%1!=0) {
[Code]....
View 0 Replies
Jun 24, 2004
This is my FLA I need to round the numbers in the farthest columns to 2 decimal points (ie: 19.00 rather than 19). My ultimate goal is to do it globally, but I'm not sure how to do it.
View 8 Replies
Jun 30, 2004
flash and I am trying to multiply two numbers where one is a decimal The result are answers with one, two and three decimal places depending upon the numbers being multiplied.
View 9 Replies
Sep 12, 2004
how I can format numbers in Flash so that it will show two decimal places regardless of the number itself?
View 4 Replies
Aug 30, 2005
I'm trying to calculate loan payments using actionscript.
i'd like to have my variable's value like this:
843.34
instead of:
843.3454 (how it's displaying now)
since I'm ultimately going to display $dollar amounts.
I know how to use Math.round() but I'd like to go to two decimal places!
View 1 Replies
Jan 3, 2004
What is the Math.???? for making a number always have 2 decimal places?
View 5 Replies
Aug 31, 2002
How do I make it so that my timer does not display the decimal places when it increments by .10? I only want to see whole numbers...
View 6 Replies
Nov 22, 2010
I have tried and tried but i cannot get a number to force show 2 decimal places.I have lots of different buttons and selection boxes that output a different value for 'sizePrice' and 'effectPrize'. An example can be seen below:
Code:
if (sizeSelectionBox.value=="size1") {
sizePrice=67.20;
calcTotalPrice();
[code]...
I need totalCost to always show 2 decimal places so if it is 60 it needs to say 60.00, if it is 67.2 it needs to say 67.20
View 4 Replies
Jun 5, 2010
I'm looking for a regex or a way to format the NumberValidator so that only decimal places are allowed.The domain="real" allows you to put integer values, but I need to force the user to but in 2.0 if they want an integer.This is because they pass through a Castor mapping file, it complains if it gets an integer when it expects a decimal.I dont want to restrict the number of decimal places, just insist that there must be a point, and a number after it.
View 1 Replies
Feb 1, 2010
I'm having some problems getting a dynamic text box to only return two decimal places. I have a time line scrubber tied to a dynamic text box that outputs what frame it is on - but I need it divided by 20, then subtract 0.05
Code:
frameTxt.text = String((ballAnimationMC.currentFrame / 20) - 0.05);
This works great most of the time...but other times returns something like 20.9999999. What can I do to ensure there are ever only two decimal places returned? See the attached FLA.
View 3 Replies