Comunidad de diseño web y desarrollo en internet online

Gran Problem XML

Citar            
MensajeEscrito el 22 Abr 2005 03:28 pm
hola amigos:

Mi problem es es siguiente estoy haciendo un reproductor mp3 q carga en una lista los ficheros mp3 q tengo en un directorio y kiero utilizar xml para ello.

tengo un php k escribe un documento xml con las canciones q ahi en dicho diretorio y lo saca asi:

<mp3>
<cancion>El Universo sobre mi.mp3</cancion>
</mp3>

aki no esta problem, el problem esta en a.s. cuando utilizo esto:

Código :

function Cargar(){
   var cnx:LoadVars = new LoadVars();
   var xml:XML = new XML();
   
   cnx.onLoad = function(ok) {
      if (ok) {
         total = cnx.total;
         songs = new Array(total);
      }
   };
   
   xml.onLoad = function(ok) {
      if (ok) {
         for(i=0;i<=total;i++) {
            songs[i] = xml.firstChild.childNodes[i].nodeValue;
      
            if (lista.text == "") {
               menu.lista.text = songs[i];
            }
            else {
               menu.lista.text += "\n";
               menu.lista.text += songs[i];
            }
         }
      }
   };
   
   cnx.load("music.php");
   xml.load("music.xml");
   
   total = -1;
   
}

se keda colgao y no se xq  :? y me anula el script flash

gracias por vuestra ayuda

Por axdaleon

25 de clabLevel



 

msie
Citar            
MensajeEscrito el 22 Abr 2005 05:39 pm

Código :

//Para utilizar acentos y ñ en archivos xml
System.useCodepage = true;

import mx.controls.List;
import mx.controls.MediaPlayback;

//Cargamos el XML
canciones = new XML();
canciones.ignoreWhite = true;
canciones.onLoad = function(success){
   if (success){
      //Shortcuts
      cancion = canciones.firstChild;
      num_total = canciones.firstChild.childNodes.length;
      
      //Creamos y llenamos la lista
      crearLista();
      //Creamos el reproductor
      crearPlayer();
   }
   else{
      trace("No se pudo cargar la lista de videos");
   }
}
canciones.load("Lista.xml"); //xml con la lista de tus canciones...

///////////////////////////////////////////////////////////////////
///////////////////////////  LISTENERS  ///////////////////////////
///////////////////////////////////////////////////////////////////

lista.addEventListener("change", alCambiar);


///////////////////////////////////////////////////////////////////
///////////////////////////  FUNCIONES  ///////////////////////////
///////////////////////////////////////////////////////////////////

function crearLista(){
   //Posicionamos la lista de las canciones
   lista.setSize(180,200);
   lista._x = 427.4;
   lista._y = 110;
   lista.hScrollPolicy = "on"; 
    lista.maxHPosition = 70;
   
   //Llenamos la lista con las canciones
   misDatos = new Array();
   lista.dataProvider = misDatos;
   
   for (var i=0; i<num_total; i++) {
      misDatos.addItem({label: cancion.childNodes[i].firstChild, data: cancion.childNodes[i].firstChild}); 
   }
}

function crearPlayer(){
   //Posicionamos el reproductor
   player.setSize(300,200);
   player._x = 125.6;
   player._y = 110;
   
   //Propiedades del reproductor
   player.controllerPolicy = "on";
   player.mediaType = "MP3";
}

//Cuando cambiamos la canción seleccionada en la lista... cargamos la nueva canción, y ejecutamos
function alCambiar (evento){
   if (evento.type == "change"){
      player.setMedia("videos/"+lista.selectedItem.data, "MP3");
      player.play();
   }
};


saludos

Por manuel_cfe

106 de clabLevel



 

msie
Citar            
MensajeEscrito el 22 Abr 2005 05:40 pm
Ademas de que no debes poner la extension .mp3 a la lista de canciones en tu archivo xml

Por manuel_cfe

106 de clabLevel



 

msie
Citar            
MensajeEscrito el 22 Abr 2005 05:58 pm
gracias manuel cfe

Por axdaleon

25 de clabLevel



 

msie

 

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