So eval() in Flash doesn't work the same as in JavaScript. Fair enough. Can someone please explain to me why the following code doesn't work in Flash (MX)?
That code should write "msg1: foo; msg2: bar" to the message window. Instead it just sits there and kind of fiddles with its hair. My guess is that the parser won't interpret the function body.PHP Code:var executors = [];
function exec(func, args) {
if (!executors[args.length]) {
var body, a;
body = "return func(";
for (a = 0 ; a < args.length ; ++a) {
if (a > 0)
body += ", ";
body += "args[" + a + "]";
}
body += ")";
executors[args.length] = new Function("func", "args", body);
}
executors[args.length](func, args);
}
function testFunc(msg1, msg2) {
trace("msg1: " + msg1 + "; msg2: " + msg2);
}
exec(testFunc,["foo","bar"]);
Any ideas on why this doesn't work in AS, but does in JS?




Reply With Quote