# Programmatic Function Calling

**URL:** <https://forum.kirupa.com/t/programmatic-function-calling/247709>\
**Category:** flash\
**Created:** [December 28, 2007, 3:47pm UTC](https://forum.kirupa.com/t/programmatic-function-calling/247709 "2007-12-28T15:47:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shadedecho](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@shadedecho](https://forum.kirupa.com/u/shadedecho)\
**Post date:** [December 28, 2007, 3:47pm UTC](https://forum.kirupa.com/t/programmatic-function-calling/247709/1 "2007-12-28T15:47:40Z")

</div>

I have used techniques in Actionscript 2 (with eval) to be able to execute a function (or a method on a class) based only on knowing it’s name in string-text form (and its path, of course).

In AS2, this was fairly easy like: eval(“this.”+someMethodName+"()")

However, AS3 no longer has that same kind of functionality.

However, it does have some other functions which are intriguing as possibilities, but I haven’t yet worked out how to do it.

I’ve got this to get a static class reference to an object’s class:

var objClass:Class = getDefinitionByName(getQualifiedClassName(obj)) as Class;

Then, using that I can say:

objClass.StaticMethod();

But, what if i had the string “StaticMethod” and I wanted to call that method on the objcLASS?

Moreover, if I have a non-static method (also defined by its string text name), on a particular instance (obj), and I want to call it, it should be the same process, right?

I’ve looked at describeType(), and it returns the XML object with an appropriate reference to a particular method, and I’m sure I could construct an E4X query to narrow down to that item, but I don’t really think that will help, as I’ve already got the string text name of the method.
