Comunidad de diseño web y desarrollo en internet online

Que es lo que pasa (php+xml+AC2)

Citar            
MensajeEscrito el 15 Ene 2009 08:22 pm
Aunque tenga conocimientos de php y sepa manejarme mas o menos en xml no tengo ni idea en ac 2.

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?

Por LeonSoft

15 de clabLevel



 

msie7
Citar            
MensajeEscrito el 15 Ene 2009 08:33 pm
hola, cambia esta parte:

Código ActionScript :

menu.load("http://localhost/tugeneradorXML.php");


ahi va la ruta http de tu script de php. Suerte.

Ps. Para incluir codigo en los post usa las etiquetas code

Por LongeVie

Claber

1741 de clabLevel

1 tutorial

Genero:Masculino  

En un lugar, re moto.

firefox
Citar            
MensajeEscrito el 15 Ene 2009 08:35 pm
Se me olvidaba, se llama AS2 no AC2 :P

Por LongeVie

Claber

1741 de clabLevel

1 tutorial

Genero:Masculino  

En un lugar, re moto.

firefox
Citar            
MensajeEscrito el 15 Ene 2009 09:31 pm
Por cierto era galeria.php (mal copy y paste) pero aun haciendo lo que has comentado tu me da un error.

Error al abrir la URL 'file:///C|/AppServ/www/garrido/undefined'

Aun siendo la ruta real.

Gracias por la ayuda

Por LeonSoft

15 de clabLevel



 

msie7
Citar            
MensajeEscrito el 15 Ene 2009 10:19 pm
Postealo como lo tienes

Por LongeVie

Claber

1741 de clabLevel

1 tutorial

Genero:Masculino  

En un lugar, re moto.

firefox
Citar            
MensajeEscrito el 15 Ene 2009 10:24 pm
//cargamos el xml
var menu = new XML();
menu.load("galeria.php");
menu.ignoreWhite = true;
}

Por LeonSoft

15 de clabLevel



 

msie7
Citar            
MensajeEscrito el 15 Ene 2009 10:29 pm
la ruta debe ser http

menu.load("http://www.host.com/galeria.php");

Por LongeVie

Claber

1741 de clabLevel

1 tutorial

Genero:Masculino  

En un lugar, re moto.

firefox
Citar            
MensajeEscrito el 15 Ene 2009 11:04 pm

Código :

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("http://localhost/garrido/galeria.php");
menu.ignoreWhite = true;
menu.onLoad = crea;
}

Por LeonSoft

15 de clabLevel



 

msie7
Citar            
MensajeEscrito el 15 Ene 2009 11:06 pm

Código :

<?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>

Por LeonSoft

15 de clabLevel



 

msie7
Citar            
MensajeEscrito el 16 Ene 2009 02:02 am
Al final lo que estaba mal era el XML no el codigo. Suerte a todos.

Por LongeVie

Claber

1741 de clabLevel

1 tutorial

Genero:Masculino  

En un lugar, re moto.

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.