Hi Holger,
coole Idee,
da spart man sich doch einen Haufen Schreibarbeit.
Hier ist noch eine etwas andere Version,
die die jeweils zuletzt zugwiesene Methode traced.
Dann kann man selektieren, was man tracen will und was nicht, ohne dass man den Namen angeben muss.
ActionScript:
traceLastMessages = function (obj) {
for (var p in obj) {
if (typeof obj[p] != 'function') {
} else {
var tmp = obj[p];
obj[p] = function () { trace('call-of> ' + arguments.callee.__methodName);arguments.callee.__originalMethod.apply(this, arguments);};
obj[p].__methodName = p;
obj[p].__originalMethod = tmp;
}
return;
}
};
// Test:
Kaefer = function () {
};
Kaefer.prototype.init = function(pStrName, pIntAge) {
this.strName = pStrName;
this.intAge = pIntAge;
};
traceLastMessages(Kaefer.prototype);
Kaefer.prototype.traceProperties = function() {
trace(this.strName + '(' + this.intAge + ')');
};
traceLastMessages(Kaefer.prototype);
objPaule = new Kaefer();
// <--
objPaule.init('Paule', '23');
objPaule.traceProperties();
// Output:
//
// call-of> init
// call-of> traceProperties
// Paule(23)
Vielen Dank für die gute Idee,
mfg r.