Well, that led me to an interesting lengthy study!
I found this neat SWC file filled with utils to simulate AS2 eval (): http://www.riaone.com/products/deval/index.html
And here is the proof that what you are looking for can really work:
package tests { import flash.display.BitmapData; import flash.display.Sprite; import flash.utils.getQualifiedClassName; import r1.deval.D; public class RandomTests extends Sprite{ public function RandomTests() { super(); var test:BitmapData = create(BitmapData, 100, 100, true, 0x00000000); trace(test); } public function create( pClass:Class, ... pArgs ):* { D.importClass(pClass); var fullQName:String = getQualifiedClassName(pClass); var qNameSplit:Array = fullQName.split("::"); var className:String = qNameSplit[1]; fullQName = qNameSplit.join("."); var statements:String = "import $0;\n" + "return new $1($2);"; var args:Array = []; for (var a:int = 0, aLen:int = pArgs.length; a < aLen; a++) { switch(pArgs[a].constructor) { case String: args[a] = "\"" + pArgs[a] + "\""; break; default: args[a] = pArgs[a]; break;
Sorry for the dependency bits (like my XString class for simple subtasks), but it works theoretically. The only problem would be to pass references to objects as argument records. But then again ... the class r1.deval.D could take it ... hmm.
In any case, I thought, perhaps it would be worth sharing.
bigp
source share