按ctrl+l键调出以下
#initclip 2
function CollapseMenuClass() {
this.init();
}
CollapseMenuClass.prototype = new MovieClip();
Object.registerClass("CollapseMenu", CollapseMenuClass);
CollapseMenuClass.prototype.init = function() {
this.menuItems = [{name:'parent1', sub:[{name:'parent1child1'}, {name:'parent1child2'}]}, {name:'parent2', sub:[{name:'parent2child1'}, {name:'parent2child2'}]}, {name:'parent3', sub:[{name:'parent3child1'}, {name:'parent3child2'}]}, {name:'parent4', sub:[{name:'parent4child1'}, {name:'parent4child2'}]}, {name:'parent5', sub:[{name:'parent5child1'}, {name:'parent5child2'}]}];
this.len = this.menuItems.length;
this.xtarget = 0;
this.ytarget = 0;
this.icount = 0;
this.addItems(this.menuItems, this.ytarget);
this.enabled = true;
};
CollapseMenuClass.prototype.getNewDepth = function() {
return (!this.depth ? (this.depth=1) : ++this.depth);
};
CollapseMenuClass.prototype.addItems = function(arr, yStart) {
var len = arr.length;
this.ytarget = ystart;
this.iid = setInterval(this, "attachOverTime", this.delay, arr, len);
};
CollapseMenuClass.prototype.attachOverTime = function(arr, len) {
if (this.icount
// ---check if primary button
if (arr[this.icount]['sub']) {
var subItemsLen = arr[this.icount]['sub'].length;
var yOffset = (subItemsLen*25)+(this.yincrement*subItemsLen);
var newName = arr[this.icount]['name'];
var whichBut = 'primary';
var setUid = this.icount;
} else {
var whichBut = 'secondary';
var newName = arr[this.icount]['name'];
// var passAction = arr[this.icount]['action'];
var yOffset = 0;
}
this.attachObjParams = {_x:this.xtarget, _y:this.ytarget, parent:this, uid:setUid, yactive:yOffset, butType:whichBut};
this.id = this.attachMovie("CollapseButton", newName, this.getNewDepth(), this.attachObjParams);
this.ytarget += this.id._height+this.yincrement;
this.icount++;
} else {
this.resetInterval(this.iid);
}
};
CollapseMenuClass.prototype.resetInterval = function(intObj) {
this.icount = 0;
this.xtarget = 0;
this.ytarget = 0;
clearInterval(intObj);
};
CollapseMenuClass.prototype.activateObj = function(uid) {
// ---activated item
var newObj = this[this.menuItems[uid]['name']];
// ---check if item is already open
if (newObj.active == true) {
newObj.active = false;
this.collapse(uid);
} else {
// ---close all items
for (var i = 0; i var tempObj = this[this.menuItems[i]['name']];
if (tempObj.active) {
var puid = i;
}
tempObj.active = false;
}
this.collapse(puid);
newObj.active = true;
// ---if submenu exists
if (this.menuItems[uid]['sub'].length>0) {
// ---expand item
this.expand(uid);
}
}
};
CollapseMenuClass.prototype.expand = function(uid) {
var activeObj = this.menuItems[uid];
var subLen = activeObj['sub'].length;
var yStart = this[activeObj['name']].yinactive+this[activeObj['name']]._height+this.yincrement;
for (var i = ++uid; i var tempObj = this[this.menuItems[i]['name']];
tempObj.y += this[activeObj['name']].yactive;
}
this.addItems(activeObj['sub'], yStart);
};
CollapseMenuClass.prototype.collapse = function(uid) {
var id = uid;
if (id != undefined) {
var activeObj = this.menuItems[id];
var activeSubLen = activeObj['sub'].length;
for (var i = 0; i var activeSubObj = this[activeObj['sub'][i]['name']];
removeMovieClip(activeSubObj);
}
id = undefined;
}
for (var i = (uid == undefined) ? 0 : ++uid; i var tempObj = this[this.menuItems[i]['name']];
tempObj.y = tempObj.yinactive;
}
};
#endinitclip
改这里
this.menuItems = [{name:'parent1', sub:[{name:'parent1child1'}, {name:'parent1child2'}]}, {name:'parent2', sub:[{name:'parent2child1'}, {name:'parent2child2'}]}, {name:'parent3', sub:[{name:'parent3child1'}, {name:'parent3child2'}]}, {name:'parent4', sub:[{name:'parent4child1'}, {name:'parent4child2'}]}, {name:'parent5', sub:[{name:'parent5child1'}, {name:'parent5child2'}]}];
好像效果不大理想
高手指点吧
我寻遍了海角和天涯
却找不到梦中的玫瑰花
我望穿了四季的天空
却看不见真正的她
就让她成为我梦中的一把吉他
用我的生命去轻抚她
就让这若隐的琴音穿越四季
让所有石化的思想都发芽