Cross Fade with Dynamic Images Problem!

Hello!!

I wonder if anyone can help debug some actionscript as I can’t seem to get the thing to work…

What I’ve done is taken a Cross Fade and tried to mix in some dynamic image loading using some script posted by Claudio elsewhere on this forum (Cheers!!).

However, nothing seems to happen???

Please, please can someone take a look at the script and offer a fix?? It would be massively appreciated!! The Script is:

ActionScript:

// Define variables.
var step = 5;
var xFadeDepth = 999;
var oldClip;

//seconds before the picture fadeout
seconds = 3;

Array.prototype.randomize = function() {
        return this.sort(function (a, b) {
                return (Math.floor(Math.random()*2) == 0) ? 1 : -1;
        });
};


//array containing your image files without the .jpg extension
movies_array = ["image1", "image2", "image3", "image4"];

//randomize the array everytime the movie runs
movies_array.randomize();
index = 0;


// Make a class to fade-out any clip.
function fadeOut() {};
fadeOut.prototype = new MovieClip();
fadeOut.prototype.onEnterFrame = function() {
	this._parent._alpha -= step;
	if (this._parent._alpha<=0) {
		this._parent._alpha = 0;
		this._parent._visible = false;
		this.removeMovieClip();
	}
};


// XOut is a blank clip in the library with
// a linkage identifier of "XOut".
Object.registerClass("XOut", fadeOut);


// Make a class to fade-in any clip.
function fadeIn() {};
fadeIn.prototype = new MovieClip();
fadeIn.prototype.onLoad = function(){
	this._parent._visible = true;
};

fadeIn.prototype.onEnterFrame = function() {
	this._parent._alpha += step;
	if (this._parent._alpha>=100) {
		this._parent._alpha = 100;
		this.removeMovieClip();
	}
};


// XIn is a blank clip in the library with
// a linkage identifier of "XIn".
Object.registerClass("XIn", fadeIn);


this.createEmptyMovieClip("container1", 3);
this.createEmptyMovieClip("container2", 2);
this.createEmptyMovieClip("loader", 1);


container1._visible = 0;
container1._alpha = 0;
container2._visible = 0;
container2._alpha = 0;


function preload(newClip) {
        loader.onEnterFrame = function() {
                var l, t;
                t = newClip.getBytesTotal();
				t = newClip.getBytesTotal();
				
                if (t && l == t ) {
                        delete this.onEnterFrame;
						clearInterval(my_interval);
                        my_interval = setInterval(pause, xFade, 50, newClip);
                }
        };
}


// XFade crossfades two clips.
// NewClip is the clip to be revealed.
// OldClip tracks the last revealed clip.
function xFade(newClip) {
	if (newClip != oldClip) {
		newClip.attachMovie("XIn", "Fader", xFadeDepth);
		oldClip.attachMovie("XOut", "Fader", xFadeDepth);
		oldClip = newClip;
	}
	if (newClip == "container1") {
		newClip = "container2";
	}
	clearInterval(my_interval);
	my_interval = setInterval(pause, seconds*1000, newClip);
}

function pause(newClip) {
        clearInterval(my_interval);
        my_interval = setInterval(pause, loadPicture, 50, newClip);
}

function loadPicture(newClip) {
        newClip.loadMovie(movies_array[index]+".jpg");
        preload(newClip);
        index == movies_array.length-1 ? index=0 : ++index;
}

loadPicture(container1);

===========================

Huge thanks in advance to anyone taking a look!!

Kind Regards
D@n