Hello,
I need help for this script. I would like to create a random picture slideshow.
It work fine but now i need to create a preloading before the next image.
Here is the code, some one can tell me how to make this preloader ?
Thankyou very much!!
iimport mx.transitions.Tween;
import mx.transitions.easing.*;
//create an array for all externally loaded images
var images:String = “001.jpg 002.jpg 003.jpg 004.jpg”;
var imagesArray:Array = new Array();
imagesArray = this.images.split(" ");
//choose a random image from that array
randomImage = Math.floor(Math.random() * imagesArray.length);
image_value = imagesArray[randomImage];
//create an empty movieclip where to load the images
var container:MovieClip = this.createEmptyMovieClip(“container”, this.getNextHighestDepth());
container._x = 0;
container._y = 0;
//load the first image
container.loadMovie(“images/”+image_value);
var imageFadeIn:Tween = new Tween(container, “_alpha”, Regular.easeOut, 0, 100, 1, true);
//a function to load the randomly selected image to a container movieclip and creating the fade ins and outs
function loadRandomImages() {
randomImage = Math.floor(Math.random()*imagesArray.length);
image_value = "images/"+imagesArray[randomImage];
var imageFadeOut:Tween = new Tween(container, "_alpha", Regular.easeOut, 100, 100, 1, true);
imageFadeOut.onMotionFinished = function() {
container.loadMovie(image_value);
var imageFadeIn:Tween = new Tween(container, "_alpha", Regular.easeOut, 0, 100, 2, true);
};
}
//use setInterval to call the function every five seconds
my_interval = setInterval(loadRandomImages, 5000);