2014-04-18 1 views
0

내 프로젝트에 https://code.google.com/p/as3scriptinglib/을 구현하는 데 문제가 있습니다.as3scriptinglib (동적 코드로드 중)이 코드를 컴파일하고 있지만 실행되지 않습니다.

코드가 컴파일되었지만 단순히 실행되지는 않습니다.

public function Main():void { 
    var loader:CompilerLoader = new CompilerLoader(); 
    loader.addEventListener(CompilerEvent.INIT, compilerInit); 
    loader.load("ESCompilerSWF.swf"); 
    trace("INIT"); 
} 

private function compilerInit(event:CompilerEvent):void { 
    var compiler:ICompiler = event.compiler; 
    trace("PREPARE",compiler.initialized); 
    var str:String = 'trace("HELLO WORLD");'; 
    try { 
     var script:IScript = compiler.compileAndLoad(str, new ScriptContext(this)); 
     script.addEventListener(ScriptErrorEvent.SCRIPT_ERROR, trace); 
     trace("Script created"); 
    } catch (e:Error) { 
     trace("ERROR", e.message); 
    } 
    trace("READY"); 

} 

그리고 그것은 출력 :

INIT 
PREPARE true 
Script created 
READY 

그래서, 당신은 코드가 as3scriptinglib에 의해 실행되지 않습니다 볼 수 있습니다. Help.

답변

0

나는이 문제를 해결했다. 스크립트를 실행 클래스는 쓰레기를 수집했다, 그래서 나는 변경 :

var script:IScript = compiler.compileAndLoad(str, new ScriptContext(this)); 

변수에 함수 외부, 같은 :

script = compiler.compileAndLoad(str, new ScriptContext(this)); 

그리고 그것은 작동합니다.

:

관련 문제