Perhaps the following syntax will help:
var func:String = "yourFunctionName"; this[func](); Regards, Keith Reinfeld From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of A. P. Damien Sent: Tuesday, November 05, 2013 10:48 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Function from string? I'm writing a game. Well, actually I guess it's more of a game engine. I want the game logic to be in a script. The script will take the form of a series of rooms, each of which can contain: . doors to other rooms . characters the player can interact with . things the player can pick up and use Any of these can have conditions on them. The condition can be expressed as: . Player must have (thing) in his inventory . Player must have at least X points . Player must have at least $Y money . Call function "f" That last seems to be a problem. I would like to be able to take a function name I've read from the script and call the corresponding function. Or, alternatively, the script can contain the name of a class which must contain a method named (for example) conditionTest. But I haven't figured out a way to convert a string to either a Function or a Class. Is there a way of doing this? If I were working in Javascript, I'd just call "eval", but that seems to be forbidden in AS3, right? Can I do this? Or do I have to put all the functions I might want to call this way in an array, and look them up that way? Or what?