CODIGO XML
<areas><area id = 'GERENCIA' dir='prueba.php?Cod_ar=2'
nivel='1'>
</area><area id = 'SUBDIRECCION SISTEMAS' dir='prueba.php?Cod_ar=3'
nivel='2'>
</area><area id = 'SUBDIRECCION ADMINISTRATIVA' dir='prueba.php?Cod_ar=4'
nivel='2'>
</area><area id = 'DESARROLLO' dir='prueba.php?Cod_ar=1'
nivel='2'>
</area><area id = 'ANALISIS' dir='prueba.php?Cod_ar=5'
nivel='3'>
</area><area id = 'CALIDAD' dir='prueba.php?Cod_ar=6'
nivel='3'>
</area></areas>
<areas><area id = 'GERENCIA' dir='prueba.php?Cod_ar=2'
nivel='1'>
</area><area id = 'SUBDIRECCION SISTEMAS' dir='prueba.php?Cod_ar=3'
nivel='2'>
</area><area id = 'SUBDIRECCION ADMINISTRATIVA' dir='prueba.php?Cod_ar=4'
nivel='2'>
</area><area id = 'DESARROLLO' dir='prueba.php?Cod_ar=1'
nivel='2'>
</area><area id = 'ANALISIS' dir='prueba.php?Cod_ar=5'
nivel='3'>
</area><area id = 'CALIDAD' dir='prueba.php?Cod_ar=6'
nivel='3'>
</area></areas>
CODIGO ACTIONSCRIPT DE FLASH
// – cargar XML
miXML = new XML();
// – ignorar espacios los espacios en blanco que podamos encontrar en el XML
miXML.ignoreWhite = true;
// – cargo el archivo XML en el objeto XML
miXML.load("menu.xml");
// – función que comprueba que el archivo ha sido cargado
function comprobar(succes) {
succes ? construirMenu() : trace("Error al parsear XML");
}
// – llamo a la función que comprueba si se cargó XML
miXML.onLoad = comprobar;
// – función construir menú
construirMenu = function () {
// – defino las posiciones _x / _y iniciales del menú
myx = 210;
myy = 40;
//Variable de comparacion
posicion = 1;
posX = myx;
s = 0;
escala = 75;
// –
// trace(miXML.firstChild.firstChild.nodeType);
//Recorre los nodos grandes (encabezado)
for (i=0; i<miXML.firstChild.childNodes.length; i++) {
// – tomar el valor id de cada nodo encabezado y asignarlo a la variable titulo
titulo = (miXML.firstChild.childNodes[i].attributes.id);
nivel = (miXML.firstChild.childNodes[i].attributes.nivel);
// – crear los encabezados de menu
this.attachMovie("boton", titulo, i+10);
itemActual = this[titulo];
// – cambiar el encabezado del menu por el id del nodo ‘encabezado’
itemActual.titulo = (titulo);
// - nivel jerarquico
itemActual.nivel = (nivel);
// posicionar _y
if(posicion != itemActual.nivel){
posicion = itemActual.nivel;
//itemActual._xscale = itemActual._yscale = escala;
myy += itemActual._height+10;
myx = posX - (itemActual._width/2);
s = 0;
}itemActual._y = myy;
itemActual._x = myx;
if (s==0){
s = 1;
posX = itemActual._x;
myx += itemActual._width+2;
}else{
myx += itemActual._width+2;
/*itemActual._xscale = itemActual._yscale = escala;
escala = escala * 0.75;*/
}
}//Fin for
};//fin construir menu
// – cargar XML
miXML = new XML();
// – ignorar espacios los espacios en blanco que podamos encontrar en el XML
miXML.ignoreWhite = true;
// – cargo el archivo XML en el objeto XML
miXML.load("menu.xml");
// – función que comprueba que el archivo ha sido cargado
function comprobar(succes) {
succes ? construirMenu() : trace("Error al parsear XML");
}
// – llamo a la función que comprueba si se cargó XML
miXML.onLoad = comprobar;
// – función construir menú
construirMenu = function () {
// – defino las posiciones _x / _y iniciales del menú
myx = 210;
myy = 40;
//Variable de comparacion
posicion = 1;
posX = myx;
s = 0;
escala = 75;
// –
// trace(miXML.firstChild.firstChild.nodeType);
//Recorre los nodos grandes (encabezado)
for (i=0; i<miXML.firstChild.childNodes.length; i++) {
// – tomar el valor id de cada nodo encabezado y asignarlo a la variable titulo
titulo = (miXML.firstChild.childNodes[i].attributes.id);
nivel = (miXML.firstChild.childNodes[i].attributes.nivel);
// – crear los encabezados de menu
this.attachMovie("boton", titulo, i+10);
itemActual = this[titulo];
// – cambiar el encabezado del menu por el id del nodo ‘encabezado’
itemActual.titulo = (titulo);
// - nivel jerarquico
itemActual.nivel = (nivel);
// posicionar _y
if(posicion != itemActual.nivel){
posicion = itemActual.nivel;
//itemActual._xscale = itemActual._yscale = escala;
myy += itemActual._height+10;
myx = posX - (itemActual._width/2);
s = 0;
}itemActual._y = myy;
itemActual._x = myx;
if (s==0){
s = 1;
posX = itemActual._x;
myx += itemActual._width+2;
}else{
myx += itemActual._width+2;
/*itemActual._xscale = itemActual._yscale = escala;
escala = escala * 0.75;*/
}
}//Fin for
};//fin construir menu
De antemano gracias por la colaboracion
