制作无限级菜单 |
| 作者:佚名 来源:不详 更新:2007-1-13 20:36:27 错误报告 我要投稿 |
原来是三级菜单,写书时想把它做为例子(第5章的第4个例子中),于是用递归改成无限级的 首先得准备xml文件 部分载图
图片如下:
 核心代码:
function addMenu(mc) { removeMenu((mc.level-1)*depthDis, (mc.level+menuLevel-1)*depthDis-1); var tempArray = []; tempArray = mc.data; var j = tempArray.length; for (var i = 0; i<j; i++) { var d = mc.level*depthDis-i-1; var t = menu.duplicateMovieClip("menu"+d, d); menuStyle(t, tempArray[i].attributes.text); t._x = mc._x+(mc._width+dis); t._y = mc._y+(hei+dis)*i; if (tempArray[i].childNodes[0] != undefined) { var tmc = t.createEmptyMovieClip("nex", 2); createNext(tmc, wid-12, 5); } t.data = tempArray[i].childNodes; t.level = mc.level+1; t.id = i; t.onRollOver = function() { addMenu(this); mc.prev = mc.curr; menuOutStyle(mc.prev); mc.curr = this; menuRollStyle(mc.curr); }; if (t.data[0] == undefined) { t.onRelease = function() { var _u = tempArray[this.id].attributes.link; if (_u != undefined) { createLoading("swf/"+_u); } }; } } } 呵,用了Tween类,效果很cool
|
|
| 文章录入:skyuu 责任编辑:skyuu |
|
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |