7 Replies Latest reply on Aug 18, 2008 3:00 PM by justria

    Eval() function?

    justria Level 1
      Does Flex provide a general eval() function, to which I may pass arbitrary expression? Or, which would be ok too, a method which at least evaluates mathematical expression?

      Thx,

      Stefan
        • 1. Re: Eval() function?
          Level 7

          "justria" <webforumsuser@macromedia.com> wrote in message
          news:g84qii$71q$1@forums.macromedia.com...
          > Does Flex provide a general eval() function, to which I may pass arbitrary
          > expression? Or, which would be ok too, a method which at least evaluates
          > mathematical expression?

          Could you give a more concrete example of what you're trying to do?


          • 2. Re: Eval() function?
            justria Level 1
            > Could you give a more concrete example of what you're trying to do?

            Use-case: A user should be able to input a mathematical formula, which in turn should be evaluated regarding a set of values and transformed into a chart.

            I meanwhile figured out, that AS 2 had an eval() function, while AS 3 no longer provides one.

            Thus, I wrote a lexer/parser for mathematical expression, which builds ASTs [abstract syntax trees]. An AST can be evaluated regarding a set of key-values pairs [bindings of names].

            On the long run, I'm going to port my LL(1) parser generator from PHP5 to AS3 - since I'm not quite happy coding parsers manually.
            • 3. Re: Eval() function?
              ntsiii Level 3
              AS2 had an eval() function but it would only resolve object references, and would not evaluate general expressions.

              Its functional replacement is to use the bracket operators.

              Someone has written an expression parser:
              http://www.riaone.com/products/deval/docs/user-guide/ug.html

              Tracy
              • 4. Re: Eval() function?
                justria Level 1
                Thanks you very much for this hint!

                That's exactly what I was looking for - and it's free! Great!
                • 5. Re: Eval() function?
                  justria Level 1
                  To push the whole thing a bit further:

                  Are there any projects, which dynamically generate AVM code to get loaded at runtime using SWFLoader?
                  • 6. Re: Eval() function?
                    ntsiii Level 3
                    I am not quite sure what you are asking.

                    There are some on-demand mxml compilers. I know there is one for Apache.

                    Tracy
                    • 7. Re: Eval() function?
                      justria Level 1
                      I'm just wondering, if there is a lib (or at least an experiment) available, which allows a Flex application to compile a program according to some syntax into an SWF file, which I may load using SWFLoader.