Collapse menu
Below is some code that I got from somewhere for a drop down menu (which works very nicely).
Now, when a menu list node is clicked, it drops down. Is there any way to get any other open menu sub-lists to close and not stay open which is what they do now?
Thanks.
Below is some code that I got from somewhere for a drop down menu (which works very nicely).
Now, when a menu list node is clicked, it drops down. Is there any way to get any other open menu sub-lists to close and not stay open which is what they do now?
Thanks.
Code:
System.useCodePage=true;
// VARIABLES
gSeparacionX = _parent.disX;
gSeparacionY = _parent.disY;
gXML=_parent.mxml;
_parent.formato=new TextFormat();
_parent.formato.font=_parent.mfont;
_parent.formato.color=_parent.mcolor;
_parent.formato.size=_parent.mtam;
tip.swapDepths(5000);
menu=new XML();
menu.load(gXML);
menu.ignoreWhite = true;
texto="cargando xml...";
menu.onLoad = arbol;
_parent.con=0;
_parent.boton0.texto="cargando xml...";
function arbol (loaded) {
if (loaded == true) {
dibujaNodo(menu);
Renderiza();
} else {
texto="error cargando xml...";
}
_parent.total=_parent.con;
}
function buscaHijos(nodo){
var tot = 0;
for(var i=0;i<nodo.childNodes.length;i++)
tot += buscaHijos(nodo.childNodes[i])
return nodo.childNodes.length + tot;
}
function dibujaNodo(param,qPos){
_parent.boton0.duplicateMovieClip("boton"+_parent.con,_parent.con);
_parent["boton"+_parent.con]._x=qPos;
_parent["boton"+_parent.con].nodo=param;
_parent["boton"+_parent.con].texto=param.attributes.name;
_parent["boton"+_parent.con].enlace=param.attributes.link;
_parent["boton"+_parent.con].activo=param.attributes.activo;
if(param.attributes.activo eq 0){
_parent["boton"+_parent.con]._alpha=50;
}
_parent["boton"+ _parent.con].seVe = true;
if(param.hasChildNodes()){
_parent["boton"+_parent.con].hijillos=buscaHijos(param);
_parent["boton"+_parent.con].desplegado=_parent.desp;
if((_parent.con eq 1) and (_parent.desp))
_parent["boton"+_parent.con].desplegado=true;
if(_parent.ima){
if(_parent.propios){
_parent["boton"+_parent.con].ima.gotoAndStop(param.attributes.icon);
}else{
_parent["boton"+_parent.con].ima.gotoAndStop("carpeta");
}
}else{
_parent["boton"+_parent.con].ima.gotoAndStop("no");
}
_parent["boton"+_parent.con].onRelease=function(){
this.desplegado=!(this.desplegado);
this.num=this._name.substring(5,8);
for(var x=Number(this.num)+1;x<=Number(this.hijillos)+Number(this.num);x++){
if((_parent["boton"+x]._x - _parent["boton"+this.num]._x) <= gSeparacionX)
_parent["boton"+x].seVe = this.desplegado;
}
Renderiza();
}
}else{
if(_parent.ima){
if(_parent.propios){
_parent["boton"+_parent.con].ima.gotoAndStop(param.attributes.icon);
}else{
_parent["boton"+_parent.con].ima.gotoAndStop("");
}
}else{
_parent["boton"+_parent.con].ima.gotoAndStop("no");
}
_parent["boton"+_parent.con].onRelease=function(){
this._parent._parent[(this._parent.func)](this.enlace);
}
}
_parent.con++;
for(var ii=0;ii<param.childNodes.length;ii++)
dibujaNodo(param.childNodes[ii],qPos+gSeparacionX);
}
_parent.boton0._visible = false;
function Renderiza(){
var qPos = 0;
for (var i = 1; i < _parent.con;i++)
_parent["boton" + i]._visible = false;
for (var i = 1; i < _parent.con;i++)
if(_parent["boton" + i].seVe){
_parent["boton" + i]._visible = true;
_parent["boton" + i]._y = qPos;
qPos += gSeparacionY;
if (!(_parent["boton" + i].desplegado))
i += _parent["boton" + i].hijillos;
}
}