// Creamos un array para almacenar los clips
var clips:Array = new Array();
//Creamos una nueva instancia XML
menuXml = new XML();
//Ignoramos los espacios en blanco
menuXml.ignoreWhite = true;
//Creamos una función asegurarnos de que se ha cargado
menuXml.onLoad = function(success) {
if (success) {
//Creamos una variable "menuItem" que nos devuelve
// una array con todos los items del menu
var menuItem = menuXml.firstChild.childNodes;
//Creamos un bucle desde 0 al total de items (menuItem.length)
for (var i = 0; i<menuItem.length; i++) {
//Accedemos al valor de cada uno de los items <boton>
Nombre = this.firstChild.childNodes[i].attributes.name;
//Accedemos al atributo url de cada uno de los items
Link = menuItem[i].attributes.url;
//Mediante attachMovie creamos instancias del clip de pelicula item_mc
var miClip:MovieClip = attachMovie("item_mc", "item_mc"+i, i);
//A cada una de las instancias le asignamos...
//La posición en la coordenada x
miClip._x = 40;
//La posición en la coordenada y
miClip._y = 20*i;
//La etiqueta de texto
miClip.etiqueta_txt.text = Nombre;
//El link al que irá
miClip.Link = Link;
// asignamos id al clip
miClip.id = i;
//lo metemos al array
clips.push(miClip);
miClip.Rectangulo_btn.onRollOver = function ()
{ clips[this.id].onEnterFrame = function ()
{
if (this._currentframe != 10)
{
this.nextFrame();
}
else
{
this.stop();
delete this.onEnterFrame;
} // end if
};
_root["pincel"+this.id].onEnterFrame = function ()
{
if (this._currentframe != 10)
{
this.nextFrame();
}
else
{
this.stop();
delete this.onEnterFrame;
} // end if
};
}
miClip.Rectangulo_btn.onRollOut = function ()
{ clips[this.id].onEnterFrame = function ()
{
if (this._currentframe != 1)
{
this.prevFrame();
}
else
{
this.stop();
delete this.onEnterFrame;
} // end if
};
_root["pincel"+this.id].onEnterFrame = function ()
{
if (this._currentframe != 1)
{
this.prevFrame();
}
else
{
this.stop();
delete this.onEnterFrame;
} // end if
};
}
//Le asignamos la acción al boton
miClip.Rectangulo_btn.onRelease=function(){
loadMovie(this._parent.Link, contenedor_mc); }
//Cerramos el bucle
}
//Cerrramos el if
}
//Cerramos la funcion
};
menuXml.load("flash_menu.xml");