A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: News and images with XML

  1. #1
    Senior Member byweb's Avatar
    Join Date
    Apr 2007
    Location
    Andalucia (spain)
    Posts
    267

    News and images with XML

    I am trying to do a newscaster with images by means of file XLM. I have a code, but in KoolMoves it doesn´t work.
    Why ?, Because probably the code is AS2.
    The code is :
    Code:
    System.useCodepage = true;
    var indice:Number;
    var noticias_xml:XML;
    function cargarDatos(_indice:Number) {
            var fecha:String;
            var titulo:String;
            var mensaje:String;
            var imagen:String;
            fecha = noticias_xml.firstChild.childNodes[_indice].attributes.fecha;
            titulo = noticias_xml.firstChild.childNodes[_indice].firstChild.firstChild.nodeValue;
            mensaje = noticias_xml.firstChild.childNodes[_indice].firstChild.nextSibling.firstChild.nodeValue;
            imagen = noticias_xml.firstChild.childNodes[_indice].lastChild.firstChild.nodeValue;
            _root.mensaje_txt.htmlText = "";
            _root.mensaje_txt.htmlText += "<p align='center'><font color='#006633' size='12'><b>"+titulo+"</b></font></p>";
            _root.mensaje_txt.htmlText += "<p><font size='10'>"+mensaje+"</font>";
            _root.mensaje_txt.htmlText += "<font color='#666666' size='10'>Publicado: "+fecha+"</font></p>";
            _root.pantalla_mc.loadMovie(imagen);
    }
    siguiente_btn.onPress = function() {
            if (noticias_xml.firstChild.childNodes[indice+1] != null) {
                    indice++;
                    cargarDatos(indice);
            }
    };   
    anterior_btn.onPress = function() {
            if (noticias_xml.firstChild.childNodes[indice-1] != null) {
                    indice--;
                    cargarDatos(indice)
            }
    };
    indice = 0;
    noticias_xml = new XML();
    noticias_xml.ignoreWhite = true;
    noticias_xml.load("noticias.xml");
    noticias_xml.onLoad = function() {
            cargarDatos(indice);
    };
    That it is necessary to change in order that the code works in KoolMoves ?
    Thanks, I don´t know to change the code AS2 to AS1.
    Last edited by byweb; 09-12-2007 at 06:06 AM.

  2. #2
    Senior Member
    Join Date
    Jun 2000
    Posts
    3,512
    It definitely is not AS1 and that is the problem.

  3. #3
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    It might be enough to change
    Code:
    var indice:Number;
    var noticias_xml:XML;
    function cargarDatos(_indice:Number) {
            var fecha:String;
            var titulo:String;
            var mensaje:String;
            var imagen:String;
    To
    Code:
    var indice;
    var noticias_xml;
    function cargarDatos(_indice) {
            var fecha;
            var titulo;
            var mensaje;
            var imagen;

  4. #4
    Senior Member byweb's Avatar
    Join Date
    Apr 2007
    Location
    Andalucia (spain)
    Posts
    267
    Thank you for your response friend blainus, now it works perfectly. Thank you again. Here I leave the file for if it helps someone. Now I am working for that appear five news and images in window. Thanks
    Last edited by byweb; 09-12-2007 at 06:06 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center