tags:

views:

25

answers:

1

I have the following;

var myName:String="myMethod";

function myMethod() {
.....
}

is there a way to call this method by using myName?

+4  A: 
this[myName](); // should work 
yourInstanceOfTheClass[myName](); // this should also work.

If it is a Static function in a class say Main.

Class Main{
   static function myMethod(){}

   static function run(){
      Main["myMethod"](); // will also work for static methods.
   }
}
John Ballinger
thanx @John Ballinger
Adnan