| 网站首页 | 免费课件 | 课件源码 | 课件制作 | 课件购买 | 课件教程 | 课堂内外 | 教案 | 试卷 | 论文 | 电脑 | 教案下载 | 
 | 试卷下载 | 论文下载 | 计划总结 | 新闻资讯 | 行业范文 | 图片 | 留言 | 术语大全 | 搞笑 | 字体 | 短信 | Flash视频教程 | 
 | 办公软件视频 | 编程设计视频 | 热门视频 | 课件论坛 | 作文写作 | 
您现在的位置: 教育资源网 >> 课件教程 >> Flash教程 >> Flash经验技巧 >> 正文 用户登录 新用户注册
免费精品 课件源程序下载 课件点播 课件定做 课件复原 课件制作指导 毕业设计 更多服务
Google




Flash经验技巧——追踪function的调用
作者:佚名    教程来源:佚名    点击数:    更新时间:2006-9-3         ★★★ 【字体:
追踪每个function 的调用,调用1个function 前输出1些调用的信息,对于调试很有帮助~~

实现的方法就是为每个function 增加1个__name__属性,再为function制作1个作为外壳的function。外壳function负责输出调试信息,再调用原函数。稍作修改就可以将信息输出为调用栈的格式,更容易看~恩。。

但还有些不足之处,譬如当多个对象的方法指向同1个function时,就不能正确地输出结果了- -。。

使用方法:

添加后面的实现代码后:


_root.q=function(){ trace(5);}// testtraceMessages(_root);_root.q();//output:[call] q (called by undefined)5


traceMessages实现代码:

traceMessages = function (pObj) {
arguments.callee.init(pObj);
arguments.callee.execute(pObj);
arguments.callee.exit();
}
//
o = traceMessages;
//
o.init = function (pObj) {
this.arrFoundedObjects = new Array();
//
this.setFounded(pObj);
}
//
o.exit = function () {
delete this.arrFoundedObject;
}
//
o.execute = function (pObj) {
ASSetPropFlags(pObj, [’__proto__’, ’prototype’], 0, 1);
for (var p in pObj) {
//
var strType = typeof(pObj[p]);
var obj = pObj[p];
//
if (!this.isContainer(obj)) continue;
if (!pObj.hasOwnProperty(p)) continue;
if (p == ’__func__’) continue;
if (this.isFounded(obj)) continue;
if (p == ’traceMessages’) continue;
//
if (strType == ’object’ || strType == ’movieclip’) {
this.setFounded(obj);
arguments.callee.call(this, obj); // recursion
continue;
}
//
this.setFounded(obj);
arguments.callee.call(this, obj); // recursion
//
var tmp = obj;
pObj[p] = function () {
trace(’[call] ’ + arguments.callee.__name__ +
’ (called by ’ + arguments.caller.__name__ + ’)’);
return arguments.callee.__func__.apply(this, arguments);
}
pObj[p].__name__ = p;
pObj[p].__func__ = tmp;
pObj[p].__func__.__name__ = p;
}
ASSetPropFlags(pObj, [’__proto__’, ’prototype’], 1, 0);
}
//
o.setFounded = function (pObj) {
this.arrFoundedObjects.push(pObj);
}
//
o.isFounded = function (pObj) {
for (var p in this.arrFoundedObjects) {
if (this.arrFoundedObjects[p] == pObj) {
return true;
}
}
return false;
}
//
o.isContainer = function (pObj) {
var strType = typeof(pObj);
return (strType == ’object’ || strType == ’function’ || strType == ’movieclip’);
}
//
delete o;

zz:
http://www.flashfanatiker.de/blog/archives/000024.html

  .
 
 
Google
我们的服务免费课件 课件定做 毕业课件设计 免费课件(QQ:375824467/电话:13996037041)  教程录入:admin    责任编辑:admin 
------------

发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口

  • 上一篇教程:
  • 下一篇教程:
  •    最新热点    最新推荐    相关教程
    AS+JS的Flash网站无刷新定位…
    一句话限制Flash中所有的动态…
    实现Flash的TextInput输入框…
    lineStyle()变化
    动态文本加入省略号
    看PDF和Flash中毒后快速解决…
    flashcom中远程共享对象Shar…
    全局变量让你告别繁琐的路径
    Flash 8中swf metadate的应用…
    好用的吸管Eyedropper功能
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)