Slide show invisible preloader question

Hello,

I am sorry for having a request for a first post. I am relatively new to flash.

Anyway, I am working on a slide show movie for my website that automatically loads random images from an XML file. However, I do want to have the current image stay on stage till the next image is loaded, and then I want the current image to fade out nicely and the new one to fade in.

The problem is that when the movie is streamed the image on stage disappears while the new one is loading, which is not what I am looking for.

Here’s the relevant part:

function randomImage(currentRandom, firstRun) {
    var ran:Number = randomNumber();
    myListener.onLoadInit = function(targetMC:MovieClip) {
        images_holder.fade(100, 5);
        loadTxt(ran);
    };
    myListener.onLoadProgress = function(targetMC:MovieClip, loadedBytes:Number, totalBytes:Number) {
        
    };
    if (loaded == filesize) {
        while (ran == currentRandom) {
            var ran:Number = randomNumber();    
        }
        loader.loadClip(imageFileName[ran], targetMC);
        pause(ran);
    }
};
function randomNumber(){
    return Math.round(Math.random() * (totalImages - 1));
};
function pause(currentRandom){
    var currentRandom:Number;
    pauseInterval = setInterval(pause_slideshow, pauseTime);    
    function pause_slideshow() {
        clearInterval(pauseInterval);
        trueFade = 1;
        randomImage(currentRandom, trueFade);
    };
};

And here’s the full code:

var pauseTime:Number = 8000;
var targetMC:MovieClip = images_holder.images_mc;
xmlImages = new XML();
xmlImages.ignoreWhite = true;
xmlImages.onLoad = loadImages;
xmlImages.load("flash_images/flash_images.xml");
import flash.filters.DropShadowFilter;
var shadowEffect:DropShadowFilter = new DropShadowFilter(3, 45, 0x000000, 90, 8, 8, 0.9, 3);
import mx.transitions.Tween;
import mx.transitions.easing.*;
MovieClip.prototype.fade = function(newAlpha:Number,speed:Number):Void{
        this.currentAlpha = this._alpha;
        this.onEnterFrame = function():Void{
                if(this.currentAlpha > newAlpha){
                        this._alpha -= speed;
                }
                else if(this.currentAlpha < newAlpha){
                        this._alpha += speed;
                }
                if (Math.abs(Math.round(newAlpha-this._alpha))<=speed){
                        this._alpha = newAlpha;
                        delete this.onEnterFrame;
                }
        };
};
var loader:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
loader.addListener(myListener);
function loadImages(loaded) {
    if (loaded) { 
        xmlFirstChild = this.firstChild;
        imageFileName = new Array();
        imageTitle = new Array();
        textColors = new Array();
        totalImages = xmlFirstChild.childNodes.length;
        for (i=0; i<totalImages; i++) {
            imageFileName.push(xmlFirstChild.childNodes*.childNodes[0].firstChild.nodeValue);
            imageTitle.push(xmlFirstChild.childNodes*.childNodes[1].firstChild.nodeValue);
            textColors.push(xmlFirstChild.childNodes*.childNodes[2].firstChild.nodeValue);
        }
        images_holder.images_mc.loadMovie(imageFileName[randomNumber()], 1);
        randomImage('', 1);
    }
};
function randomImage(currentRandom, firstRun) {
    var ran:Number = randomNumber();
    myListener.onLoadInit = function(targetMC:MovieClip) {
        images_holder.fade(100, 5);
        loadTxt(ran);
    };
    myListener.onLoadProgress = function(targetMC:MovieClip, loadedBytes:Number, totalBytes:Number) {
        
    };
    if (loaded == filesize) {
        while (ran == currentRandom) {
            var ran:Number = randomNumber();    
        }
        loader.loadClip(imageFileName[ran], targetMC);
        pause(ran);
    }
};
function randomNumber(){
    return Math.round(Math.random() * (totalImages - 1));
};
function pause(currentRandom){
    var currentRandom:Number;
    pauseInterval = setInterval(pause_slideshow, pauseTime);    
    function pause_slideshow() {
        clearInterval(pauseInterval);
        trueFade = 1;
        randomImage(currentRandom, trueFade);
    };
};
function loadTxt(ran){
        text_holder.descr_txt._x=5;
        text_holder.descr_txt._y=10;
        text_holder.descr_txt.textColor = textColors[ran];
        text_holder.descr_txt.text = imageTitle[ran];
        text_holder.descr_txt.text = text_holder.descr_txt.text.toUpperCase();
        var xScaleT:Tween  = new Tween(text_holder, "_x", Strong.easeOut, 0, 55, 16, true); 
        var xScaleT:Tween  = new Tween(text_holder, "_alpha", Strong.easeOut, 100, 0, 7, true);
        text_holder._alpha = 0;
}

So far I guess that it has something to do with onLoadProgress, but I have no idea what to do and google isn’t really helping.

Also, is there a way for me to replace the pause function to use something instead of set interval? it seems to ignore the loading progress altogether.

Any help would be greatly appreciated!

Thanks! :slight_smile: