treeTrace = function (pObj, pStrName, pBlnUnhide) { arguments.callee.init(pObj, pStrName, pBlnUnhide); arguments.callee.doTreeTrace(); }; // o = treeTrace; // o.init= function(pObj, pStrName, pBlnUnhide){ this.STR_EMPTY_DEPTHS = ' '; this.STR_FILLED_DEPTHS = ' |'; this.STR_OUTPUT_TEMPLATE = '__[{OBJ_NAME}:[{OBJ_TYPE}] = {OBJ_VALUE}]'; // this.blnUnhide = pBlnUnhide; this.blnStrict = this.blnUnhide; // this.intCurDepths = -1; this.arrActiveDepthsStack = new Array(); this.arrCurValueObjectArray = null; this.stackValueObjectArrays = new Array(); // this.intFoundObjects = 0; // this.setHiddenId(pObj); this.setHiddenTracedFlag(pObj); // if (this.blnUnhide) this.unhideProperties(pObj); // this.objCurValueObject = {strName: pStrName, mixedValue: pObj, intDepths: 0}; }; // o.doTreeTrace = function(){ this.printLine(); // this.traceLine(); this.addDepths(); // while (this.popValueObjectArray()){ // this.setCurDepths(); // this.traverseCurObject(); // this.setHiddenTracedFlag(this.objCurValueObject.mixedValue); } // this.printLine(); }; // o.printLine = function(){ trace("----------------------------------------------------"); }; // o.traceLine = function(){ var obj = this.objCurValueObject.mixedValue; var strId = (obj.__hiddenId__ != undefined) ? ' #' + obj.__hiddenId__ : ''; var strIsRef = (this.isAllreadyTraced(obj)) ? ' refers' : ''; // var hashTplReplace = new Object(); hashTplReplace['OBJ_NAME'] = this.objCurValueObject.strName; hashTplReplace['OBJ_TYPE'] = this.getExtendedType(obj) + strIsRef + strId; hashTplReplace['OBJ_VALUE'] = this.objCurValueObject.mixedValue; // trace(this.arrActiveDepthsStack.join('') + this.getFilledTemplate(hashTplReplace)); }; // o.getExtendedType = function (pObj) { if (typeof(pObj) == 'string') return 'string'; if (typeof(pObj) == 'number') return 'number'; if (typeof(pObj) == 'movieclip') return 'movieclip'; if (typeof(pObj) == 'boolean') return 'boolean'; if (typeof(pObj) == 'function') return 'function'; // if (pObj.constructor == Array) return 'array'; if (pObj.constructor == Sound) return 'sound'; if (pObj.constructor == XML) return 'xml'; if (pObj.constructor == XMLNode) return 'xmlnode'; if (pObj.constructor == LoadVars) return 'loadvars'; // if (pObj.strClassName != undefined) return pObj.strClassName; // return typeof(pObj); }; // o.getFilledTemplate = function(pHashValueByTemplateVar){ var strReturn = this.STR_OUTPUT_TEMPLATE; // for (var strName in pHashValueByTemplateVar) { strReturn = strReturn.split('{' + strName + '}').join(pHashValueByTemplateVar[strName]); } // return strReturn; }; // o.addDepths = function(){ this.intCurDepths++; this.pushValueObjectArray(); this.arrActiveDepthsStack.push(this.STR_FILLED_DEPTHS); }; // o.pushValueObjectArray = function(){ var obj = this.objCurValueObject.mixedValue; // if (this.blnUnhide) { this.unhideProperties(obj); } // var arrValueObjects = new Array(); // for (var strName in obj) { // if (this.blnStrict) { if (!obj.hasOwnProperty(strName) && obj != _global) continue; } // arrValueObjects.push(this.createObject(strName, obj[strName])); } // if (arrValueObjects.length > 0) { this.stackValueObjectArrays.push(arrValueObjects); } }; // o.unhideProperties = function(pObj) { ASSetPropFlags(pObj, null, 0, 1); ASSetPropFlags(pObj, ['__hiddenIsTraced__'], 1, 0); ASSetPropFlags(pObj, ['__hiddenId__'], 1, 0); } // o.createObject = function(pStrName, pValue){ if (this.isContainer(pValue)) { this.markContainerAsFound(pValue); } // return {strName: pStrName, mixedValue: pValue, intDepths: this.intCurDepths}; }; // o.popValueObjectArray = function(){ this.arrCurValueObjectArray = this.stackValueObjectArrays.pop(); return this.arrCurValueObjectArray != undefined; }; // o.setCurDepths = function(){ this.chopActiveDepthsStack(); this.intCurDepths = this.arrCurValueObjectArray[0].intDepths; }; // o.chopActiveDepthsStack = function(){ var intDeleteCount = this.intCurDepths - this.arrCurValueObjectArray[0].intDepths; this.arrActiveDepthsStack.splice(-intDeleteCount, intDeleteCount); }; // o.traverseCurObject = function(){ while (this.setCurValueObject()) { var obj = this.objCurValueObject.mixedValue; // this.setHiddenId(obj); // this.traceLine(); // if (this.isContainer(obj) && !this.isAllreadyTraced(obj)) { // if (this.hasMoreSiblingObjectsToExamine()) { this.saveSiblingObjects(); } else { this.markCurDepthsInactive(); } this.addDepths(); break; } } }; // o.setHiddenId = function (pObj) { if (this.isContainer(pObj) && !this.isAllreadyTraced(pObj)) { pObj.__hiddenId__ = this.intFoundObjects++; // ASSetPropFlags(pObj, ['__hiddenId__'], 1, 0); } }; // o.setHiddenTracedFlag = function (pObj) { if (this.isContainer(pObj)) { pObj.__hiddenIsTraced__ = true; // ASSetPropFlags(pObj, ['__hiddenIsTraced__'], 1, 0); } }; // o.isAllreadyTraced = function (pObj) { return (pObj.hasOwnProperty('__hiddenIsTraced__')); } // o.setCurValueObject = function(){ this.objCurValueObject = this.arrCurValueObjectArray.pop(); return this.objCurValueObject != undefined; }; // o.isContainer = function(pObj){ var strType = typeof(pObj); return (strType == 'object') || (strType == 'function') || (strType == 'movieclip'); }; // o.hasMoreSiblingObjectsToExamine = function(){ return (this.arrCurValueObjectArray.length > 0); }; // o.saveSiblingObjects = function(){ this.stackValueObjectArrays.push(this.arrCurValueObjectArray); }; // o.markCurDepthsInactive = function(){ this.arrActiveDepthsStack[this.intCurDepths] = this.STR_EMPTY_DEPTHS; }; // delete o; ASSetPropFlags(this, ['treeTrace'], 1, 0); // Test obj = new Object(); obj.a1 = 42; obj.a2 = new Array(); obj.a2[0] = new LoadVars(); obj.a2[1] = new Sound(); obj.a3 = 'test'; obj.a4 = 'test'; obj.a5 = new Object(); obj.a6 = 'test'; obj.a7 = function () {}; obj.a8 = 'test'; obj.a9 = new Object(); obj.a9.b1 = new Object(); obj.a9.b2 = 'test'; obj.a10 = new Object(); obj.a10.b1 = new Object(); obj.a10.b1.c1 = new Object(); obj.a10.b1.c1.d1 = new Object(); obj.a11 = new Object(); obj.a11.b1 = 'test'; obj.a12 = 'test'; obj.a13 = obj; obj.a14 = new Object(); obj.a14.b1 = obj.a14; obj.a15 = new Object(); obj.a15.b1 = new Object(); obj.a15.b2 = new Object(); obj.a15.b3 = new Object(); // Test treeTrace(obj, 'obj'); // Output: /* ---------------------------------------------------- __[obj:[object refers #0] = [object Object]] |__[a1:[number] = 42] |__[a2:[array #1] = ,[object Object]] | |__[0:[loadvars #2] = ] | |__[1:[sound #3] = [object Object]] |__[a3:[string] = test] |__[a4:[string] = test] |__[a5:[object #4] = [object Object]] |__[a6:[string] = test] |__[a7:[function #5] = [type Function]] |__[a8:[string] = test] |__[a9:[object #6] = [object Object]] | |__[b1:[object #7] = [object Object]] | |__[b2:[string] = test] |__[a10:[object #8] = [object Object]] | |__[b1:[object #9] = [object Object]] | |__[c1:[object #10] = [object Object]] | |__[d1:[object #11] = [object Object]] |__[a11:[object #12] = [object Object]] | |__[b1:[string] = test] |__[a12:[string] = test] |__[a13:[object refers #0] = [object Object]] |__[a14:[object #13] = [object Object]] | |__[b1:[object refers #13] = [object Object]] |__[a15:[object #14] = [object Object]] |__[b1:[object #15] = [object Object]] |__[b2:[object #16] = [object Object]] |__[b3:[object #17] = [object Object]] ---------------------------------------------------- */ //treeTrace(_global, '_global', true);