as3scriptinglib is a library that aims to provide an API for compiling and executing runtime ActionScript/JavaScript within the Flash client (no server required). It uses Adobe’s ECMAScript 4 compiler from the Tamarin project. The library is also able to execute compiled code in the scope of any object and control which classes and functions are exposed to the script domain.

It’s important to note that there are several bugs in Adobe’s compiler that will cause the library to choke on perfectly good script. A Flex app is available for testing and has a few examples included in the left-hand column.


import com.newgonzo.scripting.ICompiler;
import com.newgonzo.scripting.utils.CompilerLoader;

var loader:CompilerLoader = new CompilerLoader();
loader.addEventListener(CompilerEvent.INIT, compilerInit);

function compilerInit(event:CompilerEvent):void {
  var compiler:ICompiler = event.compiler;
  compiler.compileAndLoad("trace('Hello World!');");
Misc . URL.