Help with flash calculator...

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.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Flash & Multimedia Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jun 8th, 2007, 20:08
New Member
Join Date: Jun 2007
Location: USA
Age: 28
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Help with flash calculator...

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,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Reply

Tags
calculator, flash

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 22:16.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved