ixlepixle
09-05-2004, 07:50 PM
Is there a way to convert a string-variable to a function call?
Consider this scenario:
I have the name of a function saved as a string, let us call it funcName.
How can I apply this function to an instance of a class that has a function with the same name?
Example:
class Test{
function myFunc(){
trace("whatever");
}
}
var myObj:Test = new Test();
var func = "myFunc";
// Trying to call the function
myObj.func();
I'm having trouble making this work.. anybody know how?:)
Consider this scenario:
I have the name of a function saved as a string, let us call it funcName.
How can I apply this function to an instance of a class that has a function with the same name?
Example:
class Test{
function myFunc(){
trace("whatever");
}
}
var myObj:Test = new Test();
var func = "myFunc";
// Trying to call the function
myObj.func();
I'm having trouble making this work.. anybody know how?:)