Call a function by its name in AS3
23 September 2009
2 Comments
Imagine you want to call a function but you don’t have its reference, only its name.
Well everything in ActionScript 3 follows pretty much the same logic. Every member of an object can be accessed via object["member_name"];
Now it should be easy to get a function from it:
var f:Function = object["function_name"] as Function;









This is exactly the line of code i need!
Thank you!
one little typo “object” should be “Object”
“object” is fine, he meant the instance of the object in where the function is. It could be also “this”:
var f:Function = this["function_name"] as Function;Leave your response!
Recent Posts
Categories
links
Meta