我的一个类的方法动态定义了事件处理函数,但我不知道如何从这样的函数访问类的实例。这是一个例子:
public dynamic class SomeClass
{
public function SomeClass():void
{
}
public function someMethod1():void
{
}
public function someMethod2(eventType:String):void
{
var funcName:String = "func" + eventType;
if (this[funcName] == null)
{
this[funcName] = function(event:*):void
{
// this.someMethod1() is not working
// "TypeError: Error #1006: someMethod1 is not a function.
};
}
this[funcName]("SOME_EVENT_TYPE");
}
}
// ...
var instance:SomeClass = new SomeClass();
instance.someMethod2();