flash actionscript:
it's been a while since I have tinkered with flash. I am trying to do some very simple math and have completely lost my senses. Say I have 2 input text boxes... Value1 and Value2 I have a dynamic box call "RESULT" to display the result of : Value1+Value2 This is very simplified for what I need to accomplish,- but what is the solution? Thanks
Thanks Keith, you have always been an incredible advisor on stuff like this.. I did set the variables at it looked like this.. Input box instances were named Value1 and Value2, the variables were v1 and v2. Dynamic instance was named Result1 and variable was r1... var Value1:Number = v1 var Value2:Number=v2 var Result1:Number=ra ra=v1+v2 I know I need to get back in the groove, but I am really missing something basic.
using variable typing won't convert a string to a number. use:
I get a NaN error in the DYNAMIC text box...
if v1 and v2 are instance names, use v1.text and v2.text instead of v1 and v2 inside the Number() function. if v1 and v2 are variable names make sure neither of your textfields have html enabled and they do not have auto kern checked.
you're welcome. auto kern enables html in your textfield. so, the variable value of a textfield that contains the number 5 actually looks something like: <TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="16" COLOR="#00FF66" LETTERSPACING="0" KERNING="0">5</FONT></P></TEXTFORMAT>
So, the very last line needs to add up all of the math in the first ten variables... following your example from before and applying that to the last line, I get the dreaded NaN... Wouldnt the formula work for simple addition of variables? trdtotval1 = Number(trditem1)*Number(trdval1); trdtotval2 = Number(trditem2)*Number(trdval2); trdtotval3 = Number(trditem3)*Number(trdval3); trdtotval4 = Number(trditem4)*Number(trdval4); trdtotval5 = Number(trditem5)*Number(trdval5); trdtotval6 = Number(trditem6)*Number(trdval6); trdtotval7 = Number(trditem7)*Number(trdval7); trdtotval8 = Number(trditem8)*Number(trdval8); trdtotval9 = Number(trditem9)*Number(trdval9); trdtotval10 = Number(trditem10)*Number(trdval10); // var trd1val:Number = trdtotval1; var trd2val:Number = trdtotval2; var trd3val:Number = trdtotval3; var trd4val:Number = trdtotval4; var trd5val:Number = trdtotval5; var trd6val:Number = trdtotval6; var trd7val:Number = trdtotval7; var trd8val:Number = trdtotval8; var trd9val:Number = trdtotval9; var trd10val:Number = trdtotval10; // trdtotal00 = Number(trd1val)+Number(trd2val)+Number(trd3val)+Number(trd4val)+Number(trd5val)+ Number(trd6val)+Number(trd7val)+Number(trd8val)+Number(trd9val)+Number(trd1val0) ;
Not that I am aware of... :) I basically need the values of the variables: trdtotval* (in the first group) to be added together for the sum of all the variables to be displayed. basically, you have shown me that the variable trdtotval1 will eaqual trditem1 multiplied by trdval1 in this code: trdtotval1 = Number(trditem1)*Number(trdval1); To give you an idea of the application, say "trditem1" (which stands for 'Trade Item') is 50 concert tickets, and "trdval1" (which stands for 'Trade Value') is equal to $10.00 (although i have yet to learn how to convert to a currency format, we just call it 10) - Then the "trdtotval1" (which stands for 'trade total value') will equal 500 ($500.00) Now, I have inputs for ten trade items and I need to get the total value for each line/item. At the end of the application, I need to complete total of ALL TEN line items. So... it would look something like this: 1. 5 10 General Admission Tickets 50 2. 5 5 Parking Passes 25 (ten items like the above) TOTAL: ------------------------------------------- 75 I need the total (75) Does that make sense?
See Keith... this is what happens when you give a 3 year old with mild learning disorders a PC with a fancy flash program. Thanks, Your lil' idiot buddy. Dave
Don't see what you're looking for? Try a search.
|