# Random Picture Gallery - need you

**URL:** <https://forum.kirupa.com/t/random-picture-gallery-need-you/245496>\
**Category:** flash\
**Created:** [November 30, 2007, 8:02am UTC](https://forum.kirupa.com/t/random-picture-gallery-need-you/245496 "2007-11-30T08:02:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![speculoos](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@speculoos](https://forum.kirupa.com/u/speculoos)\
**Post date:** [November 30, 2007, 8:02am UTC](https://forum.kirupa.com/t/random-picture-gallery-need-you/245496/1 "2007-11-30T08:02:38Z")

</div>

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);
