Revision: 45372
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 29, 2011 01:43 by scottwatkins
Initial Code
/** * ActionScript 3 Call a Function by String Representation of Function Name * * This will allow you to execute a function if you only have the function name * as a string. The compiler won't catch any issues with this, so be careful with * it. However, it can save a lot of time and code if used correctly. * * The first argument to "apply" is the object that the function should apply to * The second argument is an Array object of arguments to pass to the function */ var functionName:String = "myFunction"; var containerObject:Object = myContainerObject; if (containerObject.hasOwnProperty(functionName)) containerObject[functionName].apply(null, [ args ]); else trace("Cannot call function: " + functionName + " does not exist in " + containerObject.id);
Initial URL
Initial Description
Initial Title
ActionScript 3 Call a Function by String Representation of Function Name
Initial Tags
actionscript, function
Initial Language
ActionScript 3