Hi guys,
I went through Kirupa’s slideshow tutorial , pretty neat and very similar to something i’ve been working on. Just one annoyance with both my slideshow and kirupa’s, the user has to wait for each image to preload as the slideshow goes through the first time…I am trying to get my head around how to successfully implement one preload at the start for ALL slideshow images. :hugegrin:
Anyone have any ideas on how to do this??? I’ve included my file below
#include "as/movieclip_lib.as"
#include "mc_tween2.as"
var delay = 3000;
//pause b/w slides (in milliseconds)
var curImage = 0;
//keeps track of current slide
var curInterval = 0;
//int id for current interval
function loadSlideshow(success) {
if (success) {
slideshow_xmlnode = this.firstChild;
directory = this.firstChild.attributes.directory;
image_array = [];
title_array = [];
var totalSlides = slideshow_xmlnode.childNodes.length;
for (var i = 0; i<totalSlides; i++) {
image_array* = slideshow_xmlnode.childNodes*.attributes.image;
title_array* = slideshow_xmlnode.childNodes*.attributes.title;
}
loadImage(directory+"/"+image_array[0]);
} else {
trace("Error! File not loaded!");
}
}
function nextImage() {
clearInterval(curInterval);
if (curImage == image_array.length-1) {
//reset back to first image
curImage = 0;
} else {
curImage++;
}
loadImage(directory+"/"+image_array[curImage]);
}
function loadImage(image) {
var container = slide_mc.createEmptyMovieClip("container_mc", 0);
var img = container.createEmptyMovieClip("img_mc", 1);
var control = container.createEmptyMovieClip("control_mc", 2);
// preloader stuff
var preloader = container.attachMovie("preloaderClip", "preloader_mc", 3);
preloader._x = this._width/2-preloader._width/2;
preloader._y = this._height/2-preloader._height/2;
trace(preloader);
desc_txt.text = title_array[curImage];
img.loadMovie(image);
control.onEnterFrame = function() {
img._alpha = 0;
var bLoaded = img.getBytesLoaded();
var bTotal = img.getBytesTotal();
if (bLoaded>0 && bLoaded<bTotal) {
preloader.percentage_txt.text = Math.floor((bLoaded/bTotal)*100)+"%";
} else if ((bLoaded == bTotal) && (bTotal>4)) {
delete control.onEnterFrame;
removeMovieClip(preloader);
//img._visible = 1;
img.tween("_alpha", 100, 0.30000, "easeInCubic", 0, function () {
curInterval = setInterval(nextImage, delay);
});
trace("finished loading: "+image);
}
};
}
slideshow_xml = new XML();
slideshow_xml.ignoreWhite = true;
slideshow_xml.onLoad = loadSlideshow;
slideshow_xml.load("slideshow/slideshow.xml");
NB: I’m using FMX04 but want the final output to be an AS 1.0 FP 6 file only.
Cheers, and thankyou in advance!