10 Replies Latest reply on Jan 20, 2011 12:33 PM by Ned Murphy

# Complex math...NOT my thing. HELP!!

Hey all,

Well, as stated, me and math are NOT friends, LOL!

I am wondering, is it at all possible to turn this Excel spreadsheet into a usable, functioning Flash file via ActionScript?

http://www.6ix8ightdesigns.com/Test/TestCalculation01.xls

Yes or no?

C.

• ###### 1. Re: Complex math...NOT my thing. HELP!!

that's a broken link.

• ###### 3. Re: Complex math...NOT my thing. HELP!!

Yes it is quite straight forward but you will have to know how to pass arguments to a function. You will also need to set up a way for a user to stipulate the type of calculation he wants to use - eg setting up the equivalent if the B8 field is 'W' 'B' or 'M' and then outputting the answer into another text field.

You will need to set up a number of variables eg:

calcB = 12/26;  //a numeric constant

calcW = 12/52;  //another numeric constant

calcM = false;  //a boolean value - if this is set to true the function reports an error

percentVal = 100;  //a percentage value input by user

the function will be something like this with the user typing the value he wants to calculate into a text field called 'inputTxt':

function excelCalc(calcType) {

if (calcType == "B") {

outputTxt.text =  Number(inputTxt.text)*calcB*(percentVal/100);

}

if (calcType == "W") {

outputTxt.text =  Number(inputTxt.text)*calcW*(percentVal/100);

}

if (calcM == true) {

output.text =  "error";

}

}

Very crude but hope this helps you a bit.

• ###### 4. Re: Complex math...NOT my thing. HELP!!

Wow...straight forward for you maybe, LOL! Sorry, like it states, math and I...mortal enemies!!

Ok, so is that code complete? Does it go on the first frame or in a movie clip or something?

Here are links to a very basic layout in Flash, along with the coresponding speadsheet:

Sorry, I'm just clueless as to what I should be doing...

C.

• ###### 5. Re: Complex math...NOT my thing. HELP!!

Please send a description of what you want it to do in relation to the cells in Excel - or just a full description in english. I will try to help but you are expecting a lot for people to reverse engineer an Excel document just to find out what you want to achieve with Flash!

• ###### 6. Re: Complex math...NOT my thing. HELP!!

Oh, I apologize...I didn't mean to make it seem that way.

I'm just looking for the FLA to perform the same way the Excel doc does. When someone types in a dollar amount (rounded to the nearest cent or 2 decimal places) into either field Text 1 or Text 2 or changes the value in field W/B/M, the output fields would change accordingly.

C.

• ###### 7. Re: Complex math...NOT my thing. HELP!!

I'm guessing that this is not possible?

C.

• ###### 8. Re: Complex math...NOT my thing. HELP!!

Yes, it is possible.  For an input textfield you want to assign an onChanged function so that when the text changes inside the textfield.  You could use...

Text1.onChanged = function(){
// update whatever output fields accordingly, for instance...

output.text = someValue + Number(Text1.text)

}

• ###### 9. Re: Complex math...NOT my thing. HELP!!

Here's my problem though...all three input boxes affect all three output boxes. Whenever any of the input boxes change in value, the three outputs should change too.

• ###### 10. Re: Complex math...NOT my thing. HELP!!

I don't see the problem, or you aren't describing it with enough detail.  Your onChanged function should then be written to update all three outputs.

1 person found this helpful