Hi All,
I have a class that I'm trying to keep as generic as possible. What i want to do is send it a string on set up that contains the name of a global function (or something similar). At some point during use I will ask the class to call this function. What's the best way to do this?
I was hoping to do something similar to this:
var instance_specific_function
= "doThisForThisInstanceOnly
()";
eval(instance_specific_fun
ction);
but it doesn't appear to work.
After reading a bit online it appears that the eval function is very limited in what it can do.
Is there a better way of doing this sort of thing? eventDispatch??
A bad approach (but perhaps the only one) could be having a generic function that receives the string and then using a whole mass of switch statements I can call the required function. Obviously this isn't very neat and I'd prefer to avoid this if possible.
Any advice, pointers, code snippets would be greatly appreciated.
Btw... I'm using Flash CS3 with actionscript 2.
Start Free Trial