Tengo un script en php que me crea el xml y intento que me pille los datos en flash, la cuestion es que he cojido un ejemplo y no consigo adaptarlo con mi script. ¿Que me falla? ¿Me podeis ayudar?.
Codigo PHP
<?
include("panel/config.php");
header("Cache-Control: no-cache, must-revalidate");
header('content-type: text/xml; charset=ISO-8859-1');
echo("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>");
?>
<etiqueta fuente="verdana" tamfuente="10" colorfuente="0x333333" columnas="4" ancho="80" alto="80">
<?
$query = "SELECT * FROM imagen ORDER BY id ASC";
$result = mysql_query ($query);
while($row = mysql_fetch_assoc($result)) {
?>
<galeria>
<enlace><?=$row["id"]?></enlace>
<titulo><?=stripslashes($row["titulo"])?></titulo>
<src>panel/subirimg/fotos/<?=$row["foto"]?></src>
<texto><?=stripslashes($row["texto"])?></texto>
</galeria>
<?
}
?>
</etiqueta>
Resultado XML:
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <etiqueta fuente="verdana" tamfuente="10" colorfuente="0x333333" columnas="4" ancho="80" alto="80">
- <galeria>
<enlace>1</enlace>
<titulo>imagen total 1123</titulo>
<src>panel/subirimg/fotos/default.gif</src>
<texto>probando esto 1123</texto>
</galeria>
- <galeria>
<enlace>8</enlace>
<titulo>2</titulo>
<src>panel/subirimg/fotos/listar.jpg</src>
<texto>2</texto>
</galeria>
</etiqueta>
Script flash (adaptado de un libro)
on(press){
_root.createEmptyMovieClip("galeria",2);
//función que crea la galería
function crea(){
//creamos los valores del formato
galeria.formato = new TextFormat();
galeria.formato.font = menu.childNodes[0].attributes.fuente;
galeria.formato.color = menu.childNodes[0].attributes.colorfuente;
galeria.formato.size = menu.childNodes[0].attributes.tamfuente;
galeria.formato.align = "center";
//repetimos según el número de nodos
for (p = 0; p < menu.childNodes[0].childNodes.length; p++){
for (x = 0; x < menu.childNodes[0].childNodes[p].childNodes.length; x++){
galeria.createEmptyMovieClip("imagen" + x, 10 + x);
galeria["imagen" + x].createTextField("txt", 4, 0, menu.childNodes[0].childNodes[p].childNodes[x].alto-8, menu.childNodes[0].childNodes[p].childNodes[x].attributes.ancho, 20);
galeria["imagen" + x].txt.setNewTextFormat(galeria.formato);
galeria["imagen" + x].enlace = menu.childNodes[0].childNodes[p].childNodes[x].attributes.enlace;
galeria["imagen" + x].texto = menu.childNodes[0].childNodes[p].childNodes[x].attributes.texto;
galeria["imagen" + x].titulo = menu.childNodes[0].childNodes[p].childNodes[x].attributes.titulo;
galeria["imagen" + x].imagen = menu.childNodes[0].childNodes[p].childNodes[x].attributes.src;
galeria["imagen" + x].createEmptyMovieClip("src", 2);
galeria["imagen" + x]._alpha = 60;
//asignamos los eventos de raton
galeria["imagen" + x].onRollOver = function (){
this._alpha = 100;
this.txt.text = this.texto;
};
galeria["imagen" + x].onRollOut = function (){
this._alpha = 60;
this.txt.text = "";
};
galeria["imagen" + x].onRelease = function (){
this._parent.createEmptyMovieClip("preview",200);
this._parent.preview.createEmptyMovieClip("src",2);
this._parent.preview.createEmptyMovieClip("cargador",3);
this._parent.preview.onRelease=function(){
this.removeMovieClip();
}
this._parent.preview.src.loadMovie(this.imagen);
this._parent.preview.cargador.onEnterFrame=function(){
if(this.src.getBytesTotal() > 50 && this.src.getBytesLoaded() >= this.src.getBytesTotal()){
this._parent.src._width=300;
this._parent.src._height=250;
}
}
}
//colocamos según valores del xml
if (x % parseInt(menu.childNodes[0].attributes.columnas) == 0){
galeria["imagen" + x]._y = galeria["imagen" + (x - parseInt(menu.menu.childNodes[0].attributes.columnas))]._y + parseInt(menu.childNodes[0].attributes.alto) + 5;
galeria["imagen" + x]._x = galeria.imagen0._x;
}else{
galeria["imagen" + x]._x = galeria["imagen" + (x - 1)]._x + parseInt(menu.childNodes[0].attributes.ancho) + 5;
galeria["imagen" + x]._y = galeria["imagen" + (x - 1)]._y;
}
}
}
//empezamos a cargar cada imagen
Cargador(0);
}
//función que carga imagen por imagen
function Cargador(y){
//si ya no hay más imagenes, finaliza la función
if (y == cuantos){
exit;
}
//cargamos la imagen
galeria["imagen" + y].src.loadMovie(galeria["imagen" + y].imagen);
//creamos un cuadro de texto para mostrar el porcentaje cargado
galeria["imagen" + y].createTextField("porcentaje", 3, 10, 10, 30, 20);
galeria["imagen" + y].porcentaje.setNewTextFormat(galeria.formato);
galeria["imagen" + y].porcentaje.text = "...";
//controlamos la carga de la imagen
galeria["imagen" + y].onEnterFrame = function (){
if (this.src.getBytesTotal() > 50 && this.src.getBytesLoaded() >= this.src.getBytesTotal()){
//reescalamos la imagen al tamaño especificado en el xml
this.src._width = _root.menu.childNodes[0].attributes.ancho;
this.src._height = _root.menu.childNodes[0].attributes.alto;
//cargamos la siguiente imagen
Cargador(++y);
//borramos innecesario
this.porcentaje.removeTextField();
delete this.onEnterFrame;
}else{
this.porcentaje.text = Math.round(this.src.getBytesLoaded() / this.src.getBytesTotal() * 100) + "%";
}
};
}
//cargamos el xml
menu = new XML();
menu.load("galeria.xml");
menu.ignoreWhite = true;
menu.onLoad = crea;
}
Que falla?