Running Actionscript Provided by Users

Occasionally I find myself needing to do simple programming (usually to solve a math problem or something…just a few variables, a loop or two, possibly a function), and while I do have access to a computer, there is no software with which to program (at least none that I’m familiar with). In such cases, it would be extremely convenient for me to have a url that would allow me to use actionscript. I would like to create an swf that contains an input text box, a button and a dynamic text box. The user should be able to type in any actionscript, having the desired output equal to a variable called actionscript_output, or any name really, just so it’s the same as txt_output’s variable. Then, when the user clicks the button, the actionscript he just typed should be processed and txt_output will display the appropriate text. If this is possible, it seems like it would be an incredibly simple task…I’m just wondering how I take the string entered by the user and have the swf process it as actionscript upon pressing the button. If I could have the little actionscript hints/clues (ei. highlighting key words, showing the parameters of functions, etc) displayed real-time in the input box as it normally is in Flash, that would be spectacular…but I suspect this would be very difficult (and not at all worth the work). I just thought I’d throw it out there in case, by some miracle, there would be a simple command to accomplish this. Thanks in advance.

There’s not really a way to do that with Flash 8. You would have to create a parser to handle all of the language constructs (keywords, operators, statements), classes, and myriads of other things that make ActionScript what it is. It would be much easier to make yourself familiar with another language that would be easier to code with on the fly. (JavaScript quickly comes to mind, since they are both ECMAscript-based)

Alternatively, you might be able to do this a bit more easily with AS3 and a server that could run the command-line SWF compiler (mxmlc) each time a string containing your AS was sent.