GregD
April 30, 2003, 8:47am
1
Hey people,
Just a quick query here, I want to be able to add the sum of 3 input text boxes and have the total be displayed in another text box.
I figure I set a variable and do something along the lines of:
Number = "_root.input1 + _root.input2 + _root.input3";
Or do I have to do this another way?
Also where should I put the code? In a button? Or can I stick it in the frame to save complications of users clicking on a button.
Thanks
G
system
April 30, 2003, 9:16am
2
you can use the onChanged event handler so you don’t need to click any button.
that would be something like this:
input1.onChanged = input2.onChanged=input3.onChanged=function() {
output.text = Number(input1.text)+Number(input2.text)+Number(input3.text);
};
hope it helps… =)
system
April 30, 2003, 10:02am
3
Thanks, I have got a bit further now, the main problem im having though is getting the values to add properlly, currently I have:
on (release) {
output = _root.output;
input1 = _root.input1;
input2 = _root.input2;
output = input1 + input2;
}
But instead of adding 1 + 1 to make 2… it just makes it 11
This is obviously a formating thing or something to do with the value being boolean, I can’t remember. If you can shed some light on this so the values are actually adding correctly I would be grateful.
system
April 30, 2003, 10:07am
4
that’s why i used Number(whatever) . flash interprets those values as strings. :-\
system
April 30, 2003, 10:26am
5
Yeah got that working thanks! But I can’t get decimal points now…
Say 15 divided by 2 = 7.5 I just get 75
on (release) {
output = _root.output;
output2 = _root.output2;
input1 = _root.input1;
input2 = _root.input2;
input3 = _root.input3;
output = (Number(input1) + Number(input2));
output2 = (Number(output) * Number(input3));
}
I eventually want to have an average and a percentage in 2 diff boxes.
Thanks!
system
April 30, 2003, 10:56am
6
S’ok got it working i hadnt allowed a . and a - in the dynamic text fields