самый простой способ - использовать класс Delegate
... он работает с использованием описанных методов, описанных Влаггом ... хотя я должен исправить, что я вообще не понимаю код ( также синтаксически неверно) ...
В противном случае попробуйте это:
class AutoBind {
/**
* shortcut for multiple bindings
* @param theClass
* @param methods
* @return
*/
public static function methods(theClass:Function, methods:Array):Boolean {
var ret:Boolean = true;
for (var i:Number = 0; i < methods.length; i++) {
ret = ret && AutoBind.method(theClass, methods[i]);
}
return ret;
}
/**
* will cause that the method of name methodName is automatically bound to the owning instances of type theClass. returns success of the operation
* @param theClass
* @param methodName
* @return
*/
public static function method(theClass:Function, methodName:String):Boolean {
var old:Function = theClass.prototype[methodName];
if (old == undefined) return false;
theClass.prototype.addProperty(methodName, function ():Function {
var self:Object = this;
var f:Function = function () {
old.apply(self, arguments);
}
this[methodName] = f;
return f;
}, null);
return true;
}
}
и добавьте это как самое последнее объявление в Blah:
private static var __init = AutoBind.methods(Blah, "f1,f2,f3".split(","));
это сделает свое дело ... обратите внимание, что вызовы f1, f2 и f3 станут медленнее, потому что им нужен один дополнительный вызов функции ...
Greetz
back2dos