Displayer for simple math equation
ericlin@ms1.hinet.net

download the fla

To make a displayer for a simple expression we use the parsing machine described in previous session. Break the expression according to operators. What we need is change the content of math function.

For example, for "+", we write Math.sum() function. But what this function does is not adding numbers together. It joins and aligns two movieClips.

For to display "a+b-c", we create a movieClip displaying "b" and the other movieClip displaying "c". The operator is "-", so we create a movieClip displaying "-", then joint them together as movieClip var2. Then we create movieClip displaying "a" and another movieclip displaying operator "+" , then join these two movieClip with var2 movieClip.

The problems here are:

1.

We must create a mother movieClip mainVar before we attach "a","+" and a "var2" movieClip. While we must create var2 movieClip first before we can attach the "b","c" and "-" movieClip.  Children movieClip must be born directly from mother. We can not create a complex child movieClip and make a mother movieClip to adopt it.  MovieClip can only attach a movie that exist in the library symbol. MovieClip can not attach a complex nested movieClip that we create on the fly.

This in fact is not a big problem. Since our recursive function just serves this by automatically stack handling.

2.

Contrarily, when we need align these movieClip, we need the width and height of child movieClip. We create movieClip from mother down to children, but when we manage the alignment, we do it from children up to mother.

3.

This technique can only display "simple" expression ?

In fact, we can use it to display extensive complex expression. Since our movie display an expression by "input string", then we need to define many keyword. For example, we define a keyword "fac(x)" means factorial of x, then we can display it as x!. We can define many many keywords to extend our displaying capability. However, that means we need to give user a "user manule" listing all these keyword. Otherwise, we need to create many glymph buttons, like the commercial software Math Type. 

¡@

¡@