3 Replies Latest reply on Oct 8, 2007 10:40 PM by atta707

    How to execute a string as AS3 code

    Bryan_Lovely
      I'm converting an application from HTML/javascript to Flex/ActionScript, and I've run into a problem. I need to be able to take a string and execute it as if it were a code statement.

      In javascript, it looks like this:

      var foo = 2;
      var bar = 3;
      var formula = "foo * bar";
      var result = eval(formula);
      alert(result);
      // 6


      How do I do this in ActionScript 3?


      Thanks!