好像不可以,我用的是as3.0,编译错误如下: 1061: Call to a possibly undefined method getMethod through a reference with static type String.不过我发现了一个新方法,所有的函数在as中也跟属性差不多,可以用Function.call或者来完成。 public function InvokeFunction(object:Object, methodName:String, param:String):Object { return object[methodName].call(object, param); }不过参数好像比较复杂,因为类似SimpleCollectionItem这种东西作为AddItem方法作为参数并且要序列化成String还是比较复杂的。
第一个参数是方法名称,第二个参数是方法参数类型的数组,比如方法有2个参数,一个String,一个Integer,
那么第二个参数为new Class[]{String.class,Integer.class}
1061: Call to a possibly undefined method getMethod through a reference with static type String.不过我发现了一个新方法,所有的函数在as中也跟属性差不多,可以用Function.call或者来完成。
public function InvokeFunction(object:Object, methodName:String, param:String):Object
{
return object[methodName].call(object, param);
}不过参数好像比较复杂,因为类似SimpleCollectionItem这种东西作为AddItem方法作为参数并且要序列化成String还是比较复杂的。