You want to be parsing your metalanguage, then. The kind of dynamic you mean exists in programming language like LISP, but for flash I would do something like…
This would be much easier in Polish Notation, but you can figure out a way around it.
I’m a function, I have a string, the first thing I do is check to see if there are math symbols in my string, if not, I return the numerical value of my string, otherwise, I figure out which is the LAST math symbol to operate on, I store that in my own private variable, then I recursively call TWO new instances of myself, giving each the two halves of the string, minus my operation. I then apply the results of calling those two functions to my private operation variable, using a switch/case or if/else block to say what value of operation translates to what real math operation.
So say my string I got at input was 44sin(4). I use mad programming skills to decide that I’m going to apply "" first, so I save my local variable operation=“multiply”, then I call two new instances of myself, to one, I give the string “4”, to the other, I give "4sin(4)
The first instance is going to return “4”, the second is going to save local operation=“multiply”, and then call two new versions of itself, one with 4, and one with sin(4).
The first of THOSE, with return 4, the second will store local operation = “sine”, and call ONE instance of itself (using coding skills to reliazize SINE only has one operand, unlike *… That Instance returns the numerical value 4
Now we just chug the numbers back together. The function instance where operation=sine, has gotten its needed numerical variable, and you’ve used if or case statements to tell it that means apply Math.sin(num) to it’s variable, and return that.
The instance that called itself with sine, has now gotten the answer to what sine 4 is, it can now use it’s operator=“multiply” to multiply the results of the two functions it called.
The instance above that, our first instance, does the same thing with its results.
Of course, that’s SOLVING a formula AFTER the numbers have been placed in, but you can have your user create the formula as text, and then define the variables. Your code that just swap the numbers for the variable names before sending the string off the the first function.