There are often odd cases when in a Flash Application you find that by design you want to call a function but only have the name of the function as a String. This could be caused by various reasons one being that the name is stored in a database as part of some settings. To accomplish this conversion we make use of the Function object.
How to Convert a String to a Function
var functionName:String = "toString";
// obtain the function handler
var namedFunction:Function = this[fName];
// execute the function and pass any desired arguments
nameFunction( arg1, arg2, ... );
Comments & Questions
Add Your Comment