Código ActionScript :
stop();
import caurina.transitions.*;
var tiempo:Timer = new Timer(10000, 0);
inicio();
function inicio(){
tiempo.addEventListener(TimerEvent.TIMER, moverfoto);
tiempo.start();
}
function moverfoto(even:TimerEvent):void{
imagesCount++;
if(imagesCount>=myXMLList.length()){
imagesCount=0;
}
miImagen=new Loader();
miImagen.contentLoaderInfo.addEventListener(Event.OPEN, cargaApertura);
miImagen.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, cargaProgreso);
miImagen.contentLoaderInfo.addEventListener(Event.COMPLETE, cargaCompleta);
miImagen.load(new URLRequest(myXMLList[imagesCount].attribute("srcBig")));
titulo.text=myXMLList[imagesCount].attribute("titulo");
fecha.text=myXMLList[imagesCount].attribute("fecha");
}
//*********************************
// VARIABLES PARA CARGA DE IMAGENES
//*********************************
var miImagen:Loader
var imagesCount:Number=0;
precarga_mc.visible=false;
holder_mc.visible=false;
//****************************
// CARGAR EL ARCHIVO XML
//****************************
//Paso 1.- Creamos un objeto contenedor de XML (myXML) y un objeto que lo organice en un arreglo de datos (myXMLList)
var myXML:XML = new XML();
var myXMLList:XMLList;
var il:XMLList;
//Paso 2.- Creamos una peticion de carga de un archivo externo
var myURLXML:URLRequest = new URLRequest("imagenes.xml");
var myLoaderXML:URLLoader = new URLLoader (myURLXML);
//Paso 3.- Creamos un Listener que active una funcion cuando se complete
// la carga.
myLoaderXML.addEventListener("complete", xmlCargado);
function xmlCargado (e:Event) {
//Almacenamos el archivo cargado en el contenedor XML
myXML= XML(e.target.data);
//Colocamos el archivo dentro de un arreglo XML
myXMLList=myXML.children();
il=myXML.children();
miImagen=new Loader();
miImagen.contentLoaderInfo.addEventListener(Event.OPEN, cargaApertura);
miImagen.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, cargaProgreso);
miImagen.contentLoaderInfo.addEventListener(Event.COMPLETE, cargaCompleta);
miImagen.load(new URLRequest(myXMLList[imagesCount].attribute("srcBig")));
titulo.text=myXMLList[imagesCount].attribute("titulo");
fecha.text=myXMLList[imagesCount].attribute("fecha");
}
//****************************
// PRECARGA DE IMAGENES
//****************************
function cargaApertura (e:Event) {
precarga_mc.visible=true;
precarga_mc.porcentaje_txt.text="";
}
function cargaProgreso (e:ProgressEvent) {
var percent:uint=e.bytesLoaded/e.bytesTotal*100;
precarga_mc.barra_mc.scaleX=percent/100;
precarga_mc.porcentaje_txt.text=String(percent)+"%";
}
function cargaCompleta (e:Event) {
holder_mc.visible=true;
holder_mc.addChild(miImagen);
holder_mc.alpha=0;
Tweener.addTween(holder_mc, { alpha:1, time:3, transition:"easeOutQuint"});
precarga_mc.visible=false;
}
uno.addEventListener(MouseEvent.CLICK,veauno);
dos.addEventListener(MouseEvent.CLICK,veados);
tres.addEventListener(MouseEvent.CLICK,veatres);
cuatro.addEventListener(MouseEvent.CLICK,veacuatro);
cinco.addEventListener(MouseEvent.CLICK,veacinco);
function veauno (MouseEvent) {
miImagen.contentLoaderInfo.addEventListener(Event.OPEN, cargaApertura);
miImagen.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, cargaProgreso);
miImagen.contentLoaderInfo.addEventListener(Event.COMPLETE, cargaCompleta);
miImagen.load(new URLRequest(myXMLList[0].attribute("srcBig")));
titulo.text=myXMLList[0].attribute("titulo");
fecha.text=myXMLList[0].attribute("fecha");
}
function veados (MouseEvent) {
miImagen.contentLoaderInfo.addEventListener(Event.OPEN, cargaApertura);
miImagen.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, cargaProgreso);
miImagen.contentLoaderInfo.addEventListener(Event.COMPLETE, cargaCompleta);
miImagen.load(new URLRequest(myXMLList[1].attribute("srcBig")));
titulo.text=myXMLList[1].attribute("titulo");
fecha.text=myXMLList[1].attribute("fecha");
}
function veatres (MouseEvent) {
miImagen.contentLoaderInfo.addEventListener(Event.OPEN, cargaApertura);
miImagen.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, cargaProgreso);
miImagen.contentLoaderInfo.addEventListener(Event.COMPLETE, cargaCompleta);
miImagen.load(new URLRequest(myXMLList[2].attribute("srcBig")));
titulo.text=myXMLList[2].attribute("titulo");
fecha.text=myXMLList[2].attribute("fecha");
}
function veacuatro (MouseEvent) {
miImagen.contentLoaderInfo.addEventListener(Event.OPEN, cargaApertura);
miImagen.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, cargaProgreso);
miImagen.contentLoaderInfo.addEventListener(Event.COMPLETE, cargaCompleta);
miImagen.load(new URLRequest(myXMLList[3].attribute("srcBig")));
titulo.text=myXMLList[3].attribute("titulo");
fecha.text=myXMLList[3].attribute("fecha");
}
function veacinco (MouseEvent) {
miImagen.contentLoaderInfo.addEventListener(Event.OPEN, cargaApertura);
miImagen.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, cargaProgreso);
miImagen.contentLoaderInfo.addEventListener(Event.COMPLETE, cargaCompleta);
miImagen.load(new URLRequest(myXMLList[4].attribute("srcBig")));
titulo.text=myXMLList[4].attribute("titulo");
fecha.text=myXMLList[4].attribute("fecha");
}
vermas.addEventListener(MouseEvent.CLICK,veLink);
function veLink (MouseEvent) {
var clicklistennow:URLRequest = new URLRequest(il[imagesCount].attribute("link"));
navigateToURL(clicklistennow,"_blank");
}
listado.addEventListener(MouseEvent.CLICK,veListado);
function veListado (MouseEvent) {
var listado:URLRequest = new URLRequest(il[imagesCount].attribute("listado"));
navigateToURL(listado,"_blank");
}
