//////////////////////////////// showObjHierarchy 1.23 ///////////////////////////////// // Oct. 2nd 2003 Tatsuo Kato (Thanks to Dave Yang, Tomohiro Ueki and Shinya Tomikawa) //////////////////////////////////////////////////////////////////////////////////////// /* A debug utility that allows to trace out properties of any object/function object recursively. Works in ActionScript 2.0 as well. Just put this .as file into the folder: \Macromedia\Flash MX 2004\en\First Run\Include and type in #include "showObjHierarchy.as" in your .fla. Usage 1 : showObjHierarchy(myObject); Usage 2 : showObjHierarchy(myObject, true); // 'true' exposes the hidden properties using ASSetPropFlags Usage 3 : showObjHierarchy(myObject, true, true); // The last 'true' stops it from enumerating objects equal to Object.prototype // such as MovieClip.prototype.__proto__ */ _global.showObjHierarchy = function(theObject, bUnhide, bDontEnumObjFuncPrototype) { var nTabs = -1; var getIndent = function () { var tabs = ""; for (var i = 0; i < nTabs; i++) { tabs += "\t"; } return tabs; } var toStr = function (obj) { nTabs++; if (bUnhide) { ASSetPropFlags(obj, null, 6, true); } var s = ""; for (var p in obj) { var pVal = obj[p]; var pType = typeof pVal; if (pType == "string") { s += getIndent() + p + ' : "' + pVal + '"\n'; } else if (pType == "number" || pType == "boolean") { s += getIndent() + p + ' : ' + pVal + "\n"; } else if (p == "registerClass" || p == "watch" || p == "unwatch" || p == "addProperty" || p == "valueOf" || p == "toString" || p == "hasOwnProperty" || p == "isPrototypeOf" || p == "apply" || p == "call" || p == "toLocaleString" || p == "isPropertyEnumerable") { s += getIndent() + p + " : " + pVal + "\n"; } else if (p == "constructor" || p == "__constructor__") { if (pVal == Object) { s += getIndent() + p + " : Object" + "\n"; } else if (pVal == Function) { s += getIndent() + p + " : Function" + "\n"; } } else if (bDontEnumObjFuncPrototype && pVal == Object.prototype) { s += getIndent() + p + " : Object.prototype" + "\n"; } else if (bDontEnumObjFuncPrototype && pVal == Function.prototype) { s += getIndent() + p + " : Function.prototype" + "\n"; //} else if (pType == "function") { //s += getIndent() + p + " : " + pVal + "\n"; } else { s += getIndent() + p + " : \n" + arguments.callee(pVal); } } nTabs--; return s; }; //return(toStr(theObject, "\n ")); trace(toStr(theObject)); };