1 Reply Latest reply on Sep 21, 2006 5:13 PM by /usr/local/ΕΨΗΕΛΩΝ

    Invoking code generated at runtime

      Is there a possibility to create at runtime a piece of code e.g. in String variable and invoke it ?

      for example something like that:

      var sf = "function xyz():void { do_something } "
      run sf

        • 1. Re: Invoking code generated at runtime
          I'm 95% sure that this can't be done, because SWF files are compiled and the Flash player does not provide a JIT compiler (unlike Java and .NET).

          I was thinking about a brute-force trick, but I'm sure it won't work. Anyway I'll tell you. You let the script create a local .as file with the script within the string variable, and then run an include("tempfile.as") instruction from a function inside an external .as file. The problem is that I don't know if .as files can be live-interpreted.

          The only trick you can do is to process the request server-side. PHP and ASP.NET allow you to run custom code and return the value you want. I have a VB.NET example on my book, about parsing math functions.
          If your application runs server-side you may opt for this elegant solution that, unfortunately, wastes bandwidth and puts your server in severe security danger.