原来是三级菜单,写书时想把它做为例子(第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 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