/****************************************************************** 递归trace函数,迭代mc里的所有实例,nLevel迭代开始层级 ******************************************************************/ function traceContent(mClip:MovieClip, nLevel:Number) { for (var sItem in mClip) { if (mClip[sItem] instanceof MovieClip) { if (String(mClip[sItem]).split(".").length>nLevel) { trace(mClip[sItem]); traceContent(mClip[sItem], nLevel+1); } } } } traceContent(my_mc, 1); /****************************************************************** 遍历Action,搜索并输出对象成员列表的函数,作者:自在幻想 ******************************************************************/ function printObj(obj, name, depth, ws) { var callee = arguments.callee; if (depth == null) { depth = 20; } if (callee.unknownId == null) { if (callee.allFuncs == null) { callee.allFuncs = []; } if (callee.allFuncNames == null) { callee.allFuncNames = []; } if (callee.allObjs == null) { callee.allObjs = []; } if (callee.allObjNames == null) { callee.allObjNames = []; } if (callee.allMcs == null) { callee.allMcs = []; } if (callee.allMcNames == null) { callee.allMcNames = []; } callee.unknownId = 0; } if (depth<=0) { return; } ASSetPropFlags(obj, null, 8, 1); var type = typeof (obj), i, sup; if (type == "undefined") { return; } else if (type == "function") { for (i=callee.allFuncs.length-1; i>=0; i--) { if (callee.allFuncs[i] == nbj) { break; } } if (i>=0) { trace("(func) "+ws+name+"()\t\t<=> "+callee.allFuncNames[i]+"()"); } else { callee.allFuncs.push(obj); callee.allFuncNames.push(name); trace("(func) "+ws+name+"()"); callee(obj.prototype, "prototype", depth-1, ws+" "); } } else if (type == "object") { for (i=callee.allObjs.length-1; i>=0; i--) { if (callee.allObjs[i] == obj) { break; } } if (i>=0) { trace("(obj) "+ws+name+"\t\t<=> "+callee.allObjNames[i]); } else { sup = null; if (obj.__proto__.constructor != null) { for (i=callee.allFuncs.length-1; i>=0; i--) { if (callee.allFuncs[i] == obj.__proto__.constructor) { break; } } if (i>=0) { sup = callee.allFuncNames[i]; } else { sup = "UnknownClass_"+callee.unknownId++; callee.allFuncs.push(obj.__proto__.constructor); callee.allFuncNames.push(sup); } trace("(obj) "+ws+name+" : [new "+sup+"]"); } else { trace("(obj) "+ws+name+" :"); } for (i in obj) { if (i == "__proto__" && sup != null) { trace("(obj) "+ws+" "+i+"\t\t: see "+sup); } else { callee(obj[i], i, depth-1, ws+" "); } } } } else if (type == "movieclip") { for (i=callee.allMcs.length-1; i>=0; i--) { if (callee.allMcs[i] == obj) { break; } } if (i>=0) { trace("(mc) "+ws+name+"\t\t<=> "+callee.allMcNames[i]); } else { callee.allMcs.push(obj); callee.allMcNames.push(name); trace("(mc) "+ws+name+" :"); for (i in obj) { callee(obj[i], i, depth-1, ws+" "); } } } else if (type == "string") { trace("(str) "+ws+name+"\t\t= \""+obj+"\""); } else if (type == "number") { trace("(num) "+ws+name+"\t\t= "+obj); } else if (type == "null") { trace("(null) "+ws+name); } return true; } //usage //printObj(Object, "Object",20,""); //printObj(Array, "Array",20,""); //printObj(_global, "_global",20,""); //printObj(this, "this", 20, ""); /****************************************************************** 暴露ActionScript的内建方法和属性 ******************************************************************/ /* ASSetPropFlags(object, properties, setTrue, setFalse) object 你想检查的对象或范围。 properties 你想改变其保护标记的属性或方法。你也可以将该项设置为null,这将起到通配符的作用“全部属性”。 setTrue 一个用于指定配置标记的整数形式的二进制编码。 这个整数的最后三位是最重要的,而且表示(从左至右)“重写保护”、“删除保护”、“隐藏”。 例如,将setTrue设置为二进制110(十六进制06或十进制6)维持重写和删除保护,但是不隐藏通过properties所指定的属性。 setFalse 另一个整数形式的二进制编码,用起来类似setTrue,只是它将属性设置为false。 setFalse二进制编码在应用setTrue之前被使用。 */ function printAllPrototype () { ASSetPropFlags(_global, null, 6, 1); // 将保护标记设置为110以便在_global范围内暴露每件事物 for (thisObject in _global) { // 列出在_global范围内的全部对象 ASSetPropFlags(_global[thisObject], null, 6, 1); // 暴露每个对象 trace("\n"+thisObject); // 显示对象名 for (props in _global[thisObject]) { // 列出每个对象的属性 trace(" - "+props); // 显示属性名 if (props == "prototype") { // 列出在下找prototype到的子项 ASSetPropFlags(_global[thisObject].prototype, null, 6, 1); // 暴露prototype下的子项 for (protoChain in _global[thisObject].prototype) { // 列出prototype下的子项 trace(" -- "+protoChain); // 显示子项名 } } } } } printAllPrototype();