He creado un Mc y lo llamo de la biblioteca con attachMovie. Dentro de este Mc hay 2 campos de texto dinamico y un mc vacio donde se carga una imagen. Los textos y la imagen recogen la informacion desde un XML.
Este sería el código del XML:
Código XML :
<botones> <item name="Acceso al web site de as" precio="500 Euros" link="http://www.as.com" image="image1.jpg" /> <item name="Web oficial del estudio de animacion 3D i-real studios" precio="600 Euros" link="http://www.i-real3D.com" image="image2.jpg" /> <item name="Página web de google" precio="750€" link="http://www.google.es" image="image3.jpg" /> </botones>
Y este el codigo AS:
Código ActionScript :
var myMenu:XML = new XML();
myMenu.ignoreWhite = true;
System.useCodepage = true;
myMenu.load("enlaces.xml");
linkBoton = new Array();
textoBoton = new Array();
PrecioBoton = new Array();
imageBoton = new Array();
myMenu.onLoad = function() {
for (var i = 0; i<this.firstChild.childNodes.length; i++) {
textoBoton[i] = this.firstChild.childNodes[i].attributes.name;
PrecioBoton[i] = this.firstChild.childNodes[i].attributes.precio;
linkBoton[i] = this.firstChild.childNodes[i].attributes.link;
imageBoton[i] = this.firstChild.childNodes[i].attributes.image;
}
creaBtns(this.firstChild.childNodes.length);
};
function creaBtns(cuantosBotones) {
var separacion = 10;//separacion a cada MC
alturaY = 10;//posY en stage
alturaX = 10;//posX en stage
for (var i = 0; i<cuantosBotones; i++) {
this.attachMovie("boton", "boton"+i, this.getNextHighestDepth());
_root["boton"+i].image_mc.loadMovie(imageBoton[i]);
_root["boton"+i].link = linkBoton[i];
_root["boton"+i].mytexto.text = textoBoton[i];
_root["boton"+i].precio.text = PrecioBoton[i];
_root["boton"+i]._x = alturaX+i*separacion+_root["boton"+i]._width*i;
_root["boton"+i]._y = alturaY;
_root["boton"+i].onRelease = function() {
getURL("javascript:muestraImagen('imageBoton[i]', 'Descripción Foto #1');");
};
}
}
Tiene tambien un link pero eso no es problema. Espero haberme explicado con claridad, sino decidmelo e intentare ser mas claro. Muchas gracias y espero que podais ayudarme
