# Calculator in Flash (action Script 2.0)



## Cool Buddy (Jul 6, 2010)

I am making a calculator in flash. I am able to design the basic interface & all the basic functions. But now i figured out that if I have say "2.1" displayed and I press the "." button, it becomes "2.1.". how to prevent this, Can anyone help?

Now, i figured out there are multiple ways in which a calculator can be made in flash. So i am giving an idea of how the numbers are displayed in my program

first I check if a calculation is to be performed
if yes

I first check if dot is displayed, if yes the number gets added as a string to the number already displayed
then I check if the number displayed is 0, if yes then the number pressed is displayed 
if both of the above are false, the number is added as a string to the number already displayed.
if a calculation is to be performed

then the number pressed is displayed



> function putnum(i) {
> if (disp_num.length == 10 && calc == 0) { //checks the length, 10 digit calculator
> }
> else {
> ...



I figured out I can use indexOf function to find if the box already contains a dot (.), but I am not able to use the function properly, please help. It is returning undefined if the box contains a single digit number, in any other case, it is working fine


----------

