PDA

Click to See Complete Forum and Search --> : Math -- Multiplication Help -- You know this stuff



Jason7178
04-30-2002, 02:22 AM
Hi,
I am trying to make a multiplication function, similar to a calculator. I need the text box on the left to be able to have numbers input, and then to click a button, and have the input number multiplied by thirty, and have the answer show up in a box next to it. Any Ideas

Jason Simpson

kilik212
04-30-2002, 11:15 PM
you might want to try attaching this to the button that triggers that calculation as a simplistic solution:


on (release) {

//name the textbox for your input with a legal variable name

myMulti = (parseFloat(TextField1) * 30);

//name the textbox for your display, set its properties to dynamic text.

DisplayField1 = myMulti

}

that should do it.

>>P




Originally posted by Jason7178
Hi,
I am trying to make a multiplication function, similar to a calculator. I need the text box on the left to be able to have numbers input, and then to click a button, and have the input number multiplied by thirty, and have the answer show up in a box next to it. Any Ideas

Jason Simpson

Jason7178
05-01-2002, 08:21 PM
That was awesome, thanks so much for the help.
I cannot thank you enough
Have a blessed day
Jason

kilik212
05-02-2002, 10:25 PM
you are very welcome. glad i could help :)

Jason7178
05-08-2002, 09:48 PM
Hi,
I am building a calculator for a presentation, that will need to have a "," in the thousands place, and fill out to 2 decimal places. I have gotten the two decimal places thing worked out except for the fact that when the answer comes out to be , lets say 2.5, the display field shows 2.5.00. The basic layout of the calc is in levels. Level 1 input text + 25 * .0025 = whatever. There are 10 levels, and at the end, I have another field that dynamically shows each levels answers added together. I will put my code at the bottom of this message, Don't laugh at me, I honestly don't know what I am doing, but have been searching through the boards peicing together information, so I am quite proud that I have any functionality at all. Please help. I still need to figure out how to fix the coma issue, and the extra .00 when the decimal ends up with .5

on (release) {
nextFrame ();
myMulti = (parseFloat(TextField1)*25*.0025);
myMulti2 = (parseFloat(TextField2)*25*.0025);
myMulti3 = (parseFloat(TextField3)*25*.0025);
myMulti4 = (parseFloat(TextField4)*25*.0025);
myMulti5 = (parseFloat(TextField5)*25*.0025);
myMulti6 = (parseFloat(TextField6)*25*.0025);
myMulti7 = (parseFloat(TextField7)*25*.0025);
myMulti8 = (parseFloat(TextField8)*25*.0025);
myMulti9 = (parseFloat(TextField9)*25*.01);
myMulti10 = (parseFloat(TextField10)*25*.05);
DisplayField1 = Math.round(myMulti*100)/100;
DisplayField2 = Math.round(myMulti2*100)/100;
DisplayField3 = Math.round(myMulti3*100)/100;
DisplayField4 = Math.round(myMulti4*100)/100;
DisplayField5 = Math.round(myMulti5*100)/100;
DisplayField6 = Math.round(myMulti6*100)/100;
DisplayField7 = Math.round(myMulti7*100)/100;
DisplayField8 = Math.round(myMulti8*100)/100;
DisplayField9 = Math.round(myMulti9*100)/100;
DisplayField10 = Math.round(myMulti10*100)/100;
myMulti11 = (parseFloat(DisplayField1)+(DisplayField2)+(Displa yField3)+(DisplayField4)+(DisplayField5)+(DisplayF ield6)+(DisplayField7)+(DisplayField8)+(DisplayFie ld9)+(DisplayField10));
DisplayField11 = Math.round(myMulti11*100)/100;
if (myMulti10*10 == Math.round(myMulti10*10)) {
DisplayField10 = myMulti10+".00";
}
if (myMulti9*10 == Math.round(myMulti9*10)) {
DisplayField9 = myMulti9+".00";
}
if (myMulti8*10 == Math.round(myMulti8*10)) {
DisplayField8 = myMulti8+".00";
}
if (myMulti7*10 == Math.round(myMulti7*10)) {
DisplayField7 = myMulti7+".00";
}
if (myMulti6*10 == Math.round(myMulti6*10)) {
DisplayField6 = myMulti6+".00";
}
if (myMulti5*10 == Math.round(myMulti5*10)) {
DisplayField5 = myMulti5+".00";
}
if (myMulti4*10 == Math.round(myMulti4*10)) {
DisplayField4 = myMulti4+".00";
}
if (myMulti3*10 == Math.round(myMulti3*10)) {
DisplayField3 = myMulti3+".00";
}
if (myMulti2*10 == Math.round(myMulti2*10)) {
DisplayField2 = myMulti2+".00";
}
if (myMulti*10 == Math.round(myMulti*10)) {
DisplayField1 = myMulti+".00";
}
}


Thanks so much for your help.
Flashkit is awesome.

Jason Simpson

Ed Mack
05-09-2002, 06:04 PM
Wow, that's long! Here's my take on it:



sum = 120120120;

function format(x){
l = x.length;
var r = "";
for(var i=l;i>-1;i--){
r = x.charAt(i) + r;
r = (i%3==1 ? "," : "") + r;
}
return r;
}


sum = format(String(sum));
// It takes a string number for input, and outputs a string

trace(sum);

Jason7178
05-10-2002, 03:31 AM
Hi,
Well, I am not exactly sure what to do with the code you gave me. where should I add the code? In a button, or frame?
Quite honestly, I am a little green when it comes to coding, and don't know what a lot of the stuff means yeat. I will add include one level of my calc for an example, and you can let me know how the code should be entered.

I have an input field called TextFeild1
I have a dynamic text box called DisplayField1
I have a line of code that states

myMulti = (parseFloat(TextField1)*25*.0025);

DisplayField1 = Math.round(myMulti*100)/100;

if (myMulti*10 == Math.round(myMulti*10)) {
DisplayField1 = myMulti+".00";
}
Thanks for the help

tublu
05-11-2002, 03:35 PM
Wow , you guys are some goodies ... why didn't I veture here before ? :(