Lector de RSS para el escritorio mediante Flash y Mdm Zinc

In: Flash| MDM Zinc

23 Nov 2007

Basándonos en el lector de RSS en Flash de Unijimpe vamos a modificarlo parcialmente para poder crearnos nuestra aplicación de escritorio con MDM Zinc.

Sobre cualquier duda con respecto al lector en flash, dirijiros a la web de Unijimpe, aquí solamente voy a explicar las modificaciones que he hecho para adaptarlo a nuestras necesidades.

Las "únicas" modificaciones que he realizado han sido, añadirle un combobox, dos textInput y un par de botones, uno para agregar feeds y otro para eliminarlos.

Los rss los almaceno en un xml y este lo guardo en el directorio temporal. Así siempre que ejecutéis el lector en vuestro ordenador tendréis todos los rss almacenados. Si quereis cambiar esto solamente teneis que tocar la línea:

Actionscript:
  1. var myVartemporal = mdm.System.Paths.temp;

La estructura del xml es muy sencilla:

XML:
  1. <sitios>
  2. <sitio url="http://feeds.feedburner.com/calleserpis">CalleSerpis</sitio>
  3. </sitios>

El código completo del lector es el siguiente:

Actionscript:
  1. Stage.scaleMode = "noScale";
  2. var rssxml:XML = new XML();
  3. rssxml.ignoreWhite = true;
  4. rssxml.onLoad = function()
  5. {
  6.    var nodo:XMLNode = rssxml.firstChild.firstChild;
  7.    var vtit:String = "";
  8.    var vurl:String = "";
  9.    var vdes:String = "";
  10.    var vcon:String = "";
  11.    for (i = 0; i <nodo.childNodes.length; i++) {
  12.       var snodo:XMLNode = nodo.childNodes[i];
  13.       switch (snodo.nodeName) {
  14.       case "title" :
  15.          vtit = snodo.firstChild.nodeValue;
  16.          break;
  17.       case "link" :
  18.          vurl = snodo.firstChild.nodeValue;
  19.          break;
  20.       case "description" :
  21.          vdes = snodo.firstChild.nodeValue;
  22.          break;
  23.       case "item" :
  24.          vcon = vcon + getContent(snodo);
  25.          break;
  26.       }
  27.    }
  28.    txttitle.htmlText = "<a href=\"" + vurl + "\">" + vtit + "</a>";
  29.    txtdescription.text = vdes;
  30.    txtcontent.htmlText = vcon;
  31. };
  32. function getContent(vxml)
  33. {
  34.    var stit:String = "";
  35.    var surl:String = "";
  36.    var sdes:String = "";
  37.    for (j = 0; j <vxml.childNodes.length; j++) {
  38.       var sxml:XMLNode = vxml.childNodes[j];
  39.       switch (sxml.nodeName) {
  40.       case "title" :
  41.          vtit = sxml.firstChild.nodeValue;
  42.          break;
  43.       case "link" :
  44.          vurl = sxml.firstChild.nodeValue;
  45.          break;
  46.       case "description" :
  47.          vdes = sxml.firstChild.nodeValue;
  48.          break;
  49.       }
  50.    }
  51.    return "<a href=\"" + vurl + "\"><b><font color=\"#990000\">" + vtit + "</font></b></a><br>" + vdes + "<br><br>";
  52. }
  53. var sitiosxml:XML = new XML();
  54. sitiosxml.ignoreWhite = true;
  55.    lo = new Object();
  56.    comboDatos = new Array();
  57. sitiosxml.onLoad = function()
  58. {
  59.     combositios.removeAll();
  60.    combositios.dataProvider = comboDatos;
  61.    for (i = 0; i <sitiosxml.firstChild.childNodes.length; i++) {
  62.       comboDatos.addItem({label:sitiosxml.firstChild.childNodes[i].firstChild.nodeValue, data:sitiosxml.firstChild.childNodes[i].attributes.url});
  63.    }
  64.    rssxml.load(sitiosxml.firstChild.childNodes[0].attributes.url);
  65.    lo.change = function(evt)
  66.    {
  67.       rssxml.load(combositios.value);
  68.    };
  69.    combositios.addEventListener('change', lo);
  70. };
  71. var myVartemporal = mdm.System.Paths.temp;
  72. var exists = mdm.FileSystem.fileExists(myVartemporal+"/sitios.xml");
  73. if( exists==false){
  74.     mdm.Application.Library.extractAllToDir(myVartemporal);
  75. }
  76.  
  77. sitiosxml.load(myVartemporal+"/sitios.xml");
  78.  
  79.  
  80. //Listener para cuando se pulsa click
  81. alPulsarEnter = new Object();
  82. alPulsarEnter.enter = function(evento) {
  83. };
  84. url_txt.addEventListener("change", alCambiar);
  85. titulo_txt.addEventListener("change", alCambiar);
  86. url_txt.addEventListener("click", alPulsarEnter);
  87. titulo_txt.addEventListener("click", alPulsarEnter);
  88.  
  89. import mx.styles.CSSStyleDeclaration;
  90. _global.styles.TextInput = new CSSStyleDeclaration();
  91. _global.styles.TextInput.setStyle("fontSize", "10");
  92. _global.styles.TextInput.setStyle("font", "Verdana");
  93.  
  94.  
  95. bot_borrar.onRelease=function(){
  96.  
  97.     comboDatos.removeItemAt(combositios.selectedIndex);
  98.  
  99.     montajexml="<sitios>";
  100.     for(i=1;i<=combositios.length;i++){
  101.        
  102.         montajexml+="<sitio url='"+comboDatos[i-1].data+"'>"+comboDatos[i-1].label+"</sitio>";
  103.        
  104.         }
  105.     montajexml+="</sitios>";   
  106.  
  107.     mdm.FileSystem.saveFileUnicode(myVartemporal+"/sitios.xml", montajexml);
  108.     sitiosxml.load(myVartemporal+"/sitios.xml");
  109.  
  110.  
  111. }
  112. bot_nuevo.onRelease=function(){
  113.     if(url_txt.text!=""){
  114.         montajexml="<sitios>";
  115.         for(i=1;i<=combositios.length;i++){
  116.            
  117.             montajexml+="<sitio url='"+comboDatos[i-1].data+"'>"+comboDatos[i-1].label+"</sitio>";
  118.            
  119.             }
  120.         montajexml+="<sitio url='"+url_txt.text+"'>"+titulo_txt.text+"</sitio>";
  121.         montajexml+="</sitios>";   
  122.        
  123.         mdm.FileSystem.saveFileUnicode(myVartemporal+"/sitios.xml", montajexml);
  124.         sitiosxml.load(myVartemporal+"/sitios.xml");   
  125.     }
  126. }
  127. stop();

Este ejemplo lo publiqué en cristalab hace ya algún tiempo pero no añadí la opción de poder editar el xml desde el propio lector.

Archivos del ejemplo
.

2 Responses to Lector de RSS para el escritorio mediante Flash y Mdm Zinc

Avatar

Sergio Gonzalez

Diciembre 14th, 2007 at 19:56

Hola que tal, navegando en la web me encontre con tu gestor de encuestas, que la verdad es el mejor que he encontrado pero tengo un pequeño problema, por que al descargar todos los archivos del gestor de encuestas no se encontraba el .fla.

Bueno tu diras para que lo necesito, y la respuesta es por que quiero cambiar un poco el aspecto (ya sabes colores y fondo).

Me sería de gran utilidad que me ayudaras en ese aspecto.

De ante mano te agradesco la atención.

Avatar

juan

Septiembre 1st, 2009 at 4:04

hola que tal la verdad que esto me abre nuevas ventanas con respecto a la informacion para el canal de television en el cual trabajo, yo uso el flash y el mdmsinc para generar los logos(mosca) y zocalos al aire y me gustaria muchisimo poder generar un zocalo con noticias urgentes (por ejemplo) que sacaria de alguna pagina con rss. pero te digo la verdad se me queman los papeles. VOS ME PODES DAR UNA MANO CON ESTO????? TE AGRADECERIA MUCHISIMO

Comment Form

Bienvenidos

Photostream

    IMAG0015IMAG0016IMAG0009IMAG0003IMAG0005Cactus nuevo