[ dblchckd @ 02.01.2007. 08:19 ] @
Kao da unutar funkcije dobijem njeno ime u as3? U as2 bi overrajdao toString funkciju:(primjer s http://chattyfig.figleaf.com/p...shcoders/2003-June/078663.html) Code: Function.prototype.toString = function(){ return "[function "+this._name+"]"; }; _global.setFunctionNames = function(scopes){ var i = 0, p; for (i; i<arguments.length; ++i){ for (p in arguments[i]){ if (typeof arguments[i][p] == "function") arguments[i][p]._name = p; } } } no wrappers or re-writing of your function definitions and its easy to turn off after the debugging is no longer needed (no use in having worthless function name variables if you only need them for debugging). Depending on how many functions you have and how scattered their definitions are, the scope arguments might get a little lengthy, but its better than assigning the name for each function individually :) Example: function joe(){ trace(arguments.callee); } bob = function(){ trace(arguments.callee); } Class = function(){ trace(arguments.callee); } Class.prototype.methodA = function(){ trace(arguments.callee); } Class.prototype.methodB = function(){ trace(arguments.callee); } setFunctionNames(this, Class.prototype); joe(); // [function joe] bob(); // [function bob] instance = new Class(); // [function Class] instance.methodA(); // [function methodA] instance.methodB(); // [function methodB] Kako problem rijesiti u as3? Ima li nacin da ne moram overrajdati toString()? :? |