Comunidad de diseño web y desarrollo en internet online

leer archivo xml

Citar            
MensajeEscrito el 07 Jul 2008 09:15 pm
hola de nuevo.

Bueno, estuve viendo este tutorial:

http://www.cristalab.com/tutoriales/114/control-de-video-flv-en-flash

y me funciono perfecto y exactamente lo q estoy buscando, sin embargo, quiero que la carga se haga dinamica, entonces en los valores donde esta la lista de reproduccion, que tendria que modificar para que lo haga leyendo el xml, donde estarian la direccion de los videos.

desde ya gracias.

saludos

Por bubudrc

Claber

591 de clabLevel

1 tutorial

 

mayo 2006

firefox
Citar            
MensajeEscrito el 08 Jul 2008 08:47 am
Solamente tendrías que enviarle una variable a esa función que sería el path a tu video, este path lo extraes del xml a tu conveniencia, lo mejor es que intentes hacerlo y cuando tengas problemas los posteas.

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 08 Jul 2008 03:10 pm
Hola, revisa este post:

http://www.cristalab.com/foros/p391950.html#391950

Suerte

Por miliciano

50 de clabLevel



Genero:Masculino  

Colombia

firefox
Citar            
MensajeEscrito el 08 Jul 2008 09:07 pm
hola, bueno, he intentado hacer mis pruebas.
pero no funcionan, no se porque:

el codigo del .fla, en el primer fotograma me quedo asi:

Código :

video_tmp="agronacion.flv"
var conexion:NetConnection = new NetConnection();
conexion.connect(null);
var stream:NetStream = new NetStream(conexion);
mi_video.attachVideo(stream);
stream.play(video_tmp);
//aseguramos 10 seg de reproduccion
stream.setBufferTime(10);
//
barra._xscale = 0;
onEnterFrame = function () {
   bu_cargado.text = stream.bufferLength;
   bu_trans.text = stream.time;
   bu_total.text = Math.round(stream.bytesTotal/1024)/1000+" mb";
};
//botones_-----------------------------------
seg.restrict = 1-9;
btn1.onPress = function() {
   stream.play(video_tmp);
};
btn1_1.onPress = function() {
   stream.close();
};
btn2.onPress = function() {
   stream.pause();
   //obvio, para hacer pausa, ojo q es lo mismo para avanzar
};
btn3.onPress = function() {
   stream.seek(0);
   // va al inicio (cero segundos)
};
btn4.onPress = function() {
   stream.seek(seg.text);
   // va al segundo q nosotros escribamos
};
//status
stream.onStatus = function(infoObject:Object) {
   if (infoObject.code == "NetStream.Play.Stop") {
      trace("acabo");
   }
   if (infoObject.code == "NetStream.Play.StreamNotFound") {
      trace("encontro error");
   }
};
//----------------------------------------------------------------------------
//ACA EMPIEZA EL COMBOBOX
import prueba.as;
//ACA TERMINA EL COMBOBOX


en este caso, en vez de que cargue manualmente cada item de los videos, intento hacerlo de un xml.

el archivo prueba.as tiene el siguiente codigo:

Código :

//create a new XML object
thisXML = new XML();
//ignore whitespace in the file
thisXML.ignoreWhite = true;
//call the LoadChartData function when the XML file is loaded
thisXML.onLoad = LoadCombo;
//load the xml file
thisXML.load("sites.xml");

function LoadCombo(success) {
 if (success) {
      //set variables
      var BaseNode=thisXML.childNodes[0];
      var ComboSites = new Array();
      var ComboURLs = new Array();
      var ThisNode;
      
      //add a default item to the combo box
      mi_combo.addItem("video_1");
      
      //get sites information
      for (i=0; i < BaseNode.childNodes.length; i++) {
         ThisNode = BaseNode.childNodes[i];
         ComboSites[i] = ThisNode.attributes["siteName"];
         ComboURLs[i] = ThisNode.attributes["siteURL"];
      //add to combo box
      mi_combo.addItem(ComboSites[i],ComboURLs[i]);
      }
   }
}
stop();


y finalmente, el archivo sites.xml, creado:

Código :

<?xml version="1.0" standalone="yes"?>
<AllSites>
   <site siteName="agronacion" siteURL="http://www.agritotal.com.ar/videos/agronacion/agronacion.flv"></site>
   <site siteName="bna" siteURL="http://www.agritotal.com.ar/videos/bna/bna.flv"></site>
   <site siteName="guarani" siteURL="http://www.agritotal.com.ar/videos/guarani/guarani.flv"></site>
</AllSites>


bueno, esto luego de leer varias cosas es lo que pude hacer, espero me ayuden a resolver este problema.
saludos.
y desde ya muchas gracias

Por bubudrc

Claber

591 de clabLevel

1 tutorial

 

mayo 2006

firefox
Citar            
MensajeEscrito el 08 Jul 2008 09:35 pm
Probá con:

Código :

System.useCodepage = true; //<- Antes de realizar la lectura

//create a new XML object
thisXML = new XML();
//ignore whitespace in the file
thisXML.ignoreWhite = true;
//call the LoadChartData function when the XML file is loaded
thisXML.onLoad = LoadCombo;
//load the xml file
thisXML.load("sites.xml");



Pone unos trace, para ver que esta trayendo el código:

Código :

for (i=0; i < BaseNode.childNodes.length; i++) {
         ThisNode = BaseNode.childNodes[i];
         trace( ThisNode.attributes["siteName"]);
         trace(ThisNode.attributes["siteURL"]);

         ComboSites.push( ThisNode.attributes["siteName"]);
         ComboURLs.push( ThisNode.attributes["siteURL"]);
      //add to combo box
      mi_combo.addItem(ComboSites[i],ComboURLs[i]);
      }


Con los resultados de los traces, podemos aclarar dudas.

Gracias.

Por miliciano

50 de clabLevel



Genero:Masculino  

Colombia

firefox
Citar            
MensajeEscrito el 08 Jul 2008 09:51 pm
como estaba antes no funcionaron los cmabios, y el combo box no cargaba nada
asi puse todo el codigo ac dentro del flash

asi quedo:

Código :

video_tmp="agronacion.flv"
var conexion:NetConnection = new NetConnection();
conexion.connect(null);
var stream:NetStream = new NetStream(conexion);
mi_video.attachVideo(stream);
stream.play(video_tmp);
//aseguramos 10 seg de reproduccion
stream.setBufferTime(10);
//
barra._xscale = 0;
onEnterFrame = function () {
   bu_cargado.text = stream.bufferLength;
   bu_trans.text = stream.time;
   bu_total.text = Math.round(stream.bytesTotal/1024)/1000+" mb";
};
//botones_-----------------------------------
seg.restrict = 1-9;
btn1.onPress = function() {
   stream.play(video_tmp);
};
btn1_1.onPress = function() {
   stream.close();
};
btn2.onPress = function() {
   stream.pause();
   //obvio, para hacer pausa, ojo q es lo mismo para avanzar
};
btn3.onPress = function() {
   stream.seek(0);
   // va al inicio (cero segundos)
};
btn4.onPress = function() {
   stream.seek(seg.text);
   // va al segundo q nosotros escribamos
};
//status
stream.onStatus = function(infoObject:Object) {
   if (infoObject.code == "NetStream.Play.Stop") {
      trace("acabo");
   }
   if (infoObject.code == "NetStream.Play.StreamNotFound") {
      trace("encontro error");
   }
};
//----------------------------------------------------------------------------
//ACA EMPIEZA EL COMBOBOX
System.useCodepage = true; //<- Antes de realizar la lectura

//create a new XML object
thisXML = new XML();
//ignore whitespace in the file
thisXML.ignoreWhite = true;
//call the LoadChartData function when the XML file is loaded
thisXML.onLoad = LoadCombo;
//load the xml file
thisXML.load("sites.xml");

function LoadCombo(success) {
 if (success) {
      //set variables
      var BaseNode=thisXML.childNodes[0];
      var ComboSites = new Array();
      var ComboURLs = new Array();
      var ThisNode;
      
      //add a default item to the combo box
      mi_combo.addItem("video_1");
      
      //get sites information
      for (i=0; i < BaseNode.childNodes.length; i++) {
         ThisNode = BaseNode.childNodes[i];
         trace( ThisNode.attributes["siteName"]);
         trace(ThisNode.attributes["siteURL"]);
         ComboSites[i] = ThisNode.attributes["siteName"];
         ComboURLs[i] = ThisNode.attributes["siteURL"];
      //add to combo box
      mi_combo.addItem(ComboSites[i],ComboURLs[i]);
      }
   }
}
stop();
//ACA TERMINA EL COMBOBOX


El trace lo que tiro fue:
agronacion
http://www.agritotal.com.ar/videos/agronacion/agronacion.flv
bna
http://www.agritotal.com.ar/videos/bna/bna.flv
guarani
http://www.agritotal.com.ar/videos/guarani/guarani.flv


o sea los nombres de los videos y las url donde estan alojadas, lo mismo que esta en el xml, ademas el combobox ya carga la lista, sin embargo, al elegir una opcion no pasa nada...



igualmente muchas gracias por tu ayuda

Por bubudrc

Claber

591 de clabLevel

1 tutorial

 

mayo 2006

firefox
Citar            
MensajeEscrito el 08 Jul 2008 10:26 pm

bubudrc escribió:

.. el combobox ya carga la lista, sin embargo, al elegir una opcion no pasa nada...


Hola, no pasa nada al presionar el combo, porque no veo por ningun lado los eventos del combo.

Revisa este tutorial,

http://www.cristalab.com/tutoriales/45/tutorial-del-componente-combobox-de-flash

Porque vas a necesitar algo así:

Código :

//Eventos
miDesplegable.addEventListener("change", alSeleccionar);
//Listeners para cuando seleccionamos alguna opcion
alSeleccionar = new Object();
alSeleccionar.change = function(evento) {
   trace("Has seleccionado "+evento.target.value);
};

Por miliciano

50 de clabLevel



Genero:Masculino  

Colombia

firefox
Citar            
MensajeEscrito el 10 Jul 2008 06:23 pm
hola amigos, lo he probado, el problema que me da, es que en ese tutorial la seleccion la realiza mediante un case, sobre las opciones definidas en la parte superior, sin embargo al leer del xml, esas opciones no estan y tendria que hacerlo por medio de los nombre que carga y eso es lo complicado y lo q me esta haciendo volver loco :oops:

agradezco su ayuda y espero poder terminar esto, como sea.
si alguien sabe como solucionarlo se lo agradecere el doble.

saludos

Por bubudrc

Claber

591 de clabLevel

1 tutorial

 

mayo 2006

firefox

 

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