-
Input box math functions
Hey, I am trying to make a simple formula thing using an input box. In the box they should be able to put a number in and let it divide by 1.3^3. I am having trouble syncing the input and the output together. I cannot get it to preform the way I want it too? Does anyone have any ideas? Thanks! -Seth
-
Senior Member
what are you trying? code?
what is the formula?
what is 'not working'? what is the error(s) you are getting?
-
Prid - Outing
Use onChanged function (I newly learned it, just before you asked this question):
Actionscript Code:
input_txt.onChanged = function(){ output_txt.text = "text changed"; }
Hope this is what you wanted, but if you want to know how to do this in flash, 1.3^3, then use this:
but I am pretty sure you already know that
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
Nice Nig, I changed it to
Actionscript Code:
onEnterFrame = function () { output_txt.text = input_txt.text/Math.pow(1.3,3); }
that allows larger numbers. However, I never got this, but how do you keep the output box from showing NAN or such. I have been out of touch with AS for a while.
-
Prid - Outing
If you mean you don't have anything in the field, then show 0, then use this:
Actionscript Code:
onEnterFrame = function () { if(output_txt.text == ""){ output_txt.text = 0; } else { output_txt.text = input_txt.text/Math.pow(1.3,3); } }
but if you mean you don't want users to type in anything else than numbers, then use this:
Actionscript Code:
output_txt.restrict = "0-9";
onEnterFrame = function () { output_txt.text = input_txt.text/Math.pow(1.3,3); }
Hope it helps
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
Senior Member
using oEnterFrames without any clean-up is bad form.
simplify what you guys have already posted:
actionscript Code:
input_txt.onChanged = function() { trace(input_txt.text/Math.pow(1.3,3)); };
-
Prid - Outing
using oEnterFrames without any clean-up is bad form.
I know, and I was about to tell Sethfx to drop it and stick to onChanged, but I was too lazy typing why he should do that, and stuff like that, so I sticked to his way - though, it is my fault since I taught him onEnterFrame xD
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
Yeah I know, but I need it to constantly check. With onChanged it only does the first character. So if I enter 80 it only does the calculation for 8.
-
Senior Member
thats not true. it fires/executes every time there is a 'change' in the field.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|