-
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.
-
It definitely is not AS1 and that is the problem.
-
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;
-
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