This is a discussion on "Help with flash calculator..." within the Flash & Multimedia Forum section. This forum, and the thread "Help with flash calculator... are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Help with flash calculator...
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
I have been working on a flash calculator and after many hours of research and much help from other people I have learned enough to write a simple calculator...however, I wanted to add comma's to the input box, and this is where I am having the trouble. It would be easier to just show you what I mean so please look here: http://www.memoryvilleusafoundation....lculate11.html
You will notice that when inputing a number to the thousands (i.e. 2000) it automatically puts the comma in the proper place, however if you put in something any higher there are serious problems in both the input box and the copycat box. Here is the code I have now: btn_mc.onPress=function(){ total_txt.text = "$"+addCommas(Number(killCommas(num1_txt.text)*5)) +".00"; total2_txt.text = "$"+addCommas(Number(killCommas(num1_txt.text)*25) )+".00"; total3_txt.text= "$"+addCommas((Number(killCommas(num1_txt.text)*25 ))+(Number(killCommas(num1_txt.text)*5)))+".00"; } function addCommas(theNumber){ numString = theNumber + ""; //convert # to string newString = ""; //return string index = 1; // string index trip = 0; // trip, as in triple. while( numString.length >= index){ if (trip!=3){ //haven't reached 3 chars yet newString = numString.charAt(numString.length - index) + newString; //add char index++; trip++; } else{ //reached 3 chars, add comma newString = "," + newString; trip=0; } } return (newString); } trace(Number("5,000") + 5); //traces "NaN" killCommas = function(s:String):String { return s.split(",").join(""); } trace(killCommas("5,000") + 5); //traces "50005" trace(Number(killCommas("5,000")) + 5); //traces "5005" num1_txt.onChanged=function(){ num1_txt.text =+addCommas(this.text); num2_txt.text =(this.text); } If someone could help me I would be forever grateful. Thanks, |
|
|
![]() |
| Tags |
| calculator, flash |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| looking for job quote calculator | bonnit | PHP Forum | 3 | May 17th, 2008 13:29 |
| Javascript calculator help with coding | Cat2008 | JavaScript Forum | 0 | May 1st, 2008 14:48 |
| Popup calculator | masonbarge | PHP Forum | 1 | Apr 19th, 2007 02:08 |
| keypad calculator | pelachrum | JavaScript Forum | 1 | Aug 8th, 2005 22:26 |
| calculator through link? | pelachrum | Web Page Design | 1 | Aug 6th, 2005 08:26 |