[AS2] Tough problem related to loadInit

Hey everyone, I’m trying to make a slideshow of sorts for a friend of mine in which a php script lists the number of files it’s found in a directory as well as the relative links to each file. The slideshow parses these values and is supposed to individually fade between two different pictures after loading the new one… but it works erratically at best. :sad2:

I’ve got everything working up to a component related to onLoadInit that honestly is just driving me crazy because I cannot for the life of me figure it out, as it works sometimes, other times not at all, etc. It’s also supposed to loop infinitely, but it won’t.

If you’d like to see what’s going on, go to http://www.themoshroom.com/moveit to see how weird it acts.

Following is the brunt of the code, which I’m just about 100% sure should work correctly.

import mx.controls.Label;
import com.mosesSupposes.fuse.*;
ZigoEngine.simpleSetup(Shortcuts,PennerEasing);
/////// Cover the Globals ///////////
stop();
Stage.showMenu = false;
Stage.align = "TL";
Stage.scaleMode = "noScale";
var mclListener:Object = new Object();
var image_mcl:MovieClipLoader = new MovieClipLoader();
_global.txto = "Enter an email for updates...";
var email:String;
var rand = randRange(0, numPics-1);
var oldrand = rand;
var rej:Number = 0;
/////////////////////////////////////
load_interval = setInterval(siteLoad, 100);//Start the Ball rolling
function siteLoad() {
	load_mc._x = Stage.width-load_mc._width;
	load_mc._y = Stage.height-load_mc._height-5;
	if (_root.getBytesLoaded() == _root.getBytesTotal()) {
		clearInterval(load_interval);
		agecheck();
	}
}
age_mc._alpha = 0;
priv_mc._alpha = 0;
////////////// Intro ///////////////////
function intro() {
	/////////// Error Catching //////////
	if (numPics == undefined || numPics == 0) {
		load_mc._visible = 0;
		//drip_mc._visible = 0;
		var errorbox:Label;
		this.createEmptyMovieClip("error_mc",this.getNextHighestDepth());
		error_mc.createObject("Label","errorbox",1000);
		error_mc.errorbox.autoSize = 1;
		error_mc.errorbox.text = "Error: There are no Pictures!!";
		error_mc.slideTo(10,10,0);
		error_mc.colorTo("0xffffff",0);
		error_mc.colorTo("0x000000",2,null,4);
		break;
	}
	//////////////////////////////////////         
	_root.attachMovie("drip","drip_mc",numPics+5);
	drip_mc._x = 0;
	drip_mc._y = 0;
	priv_mc._x = Stage.width-priv_mc._width-5;
	priv_mc._y = Stage.height-priv_mc._height-5;
	priv_mc._alpha = 0;
}
///////////////////////////////////////
function init() {
	load_mc.swapDepths(numPics+1);
	priv_mc.swapDepths(numPics+2);
	priv2_mc.swapDepths(numPics+3);
	priv_mc.alphaTo(100,1);
	for (diz=1; diz<=numPics; diz++) {
		this.createEmptyMovieClip("bg"+diz+"_mc",diz);
		this["bg"+diz+"_mc"]._alpha = 0;
	}
	slideshow();
}
/////// Image Loader ////////////////
mclListener.onLoadInit = function(target_mc:MovieClip) {
	age_mc._visible = 0;
	target_mc.forceSmoothing = true;
	transition(8,target_mc);// Currently have randRange set to pick 1 Possible Transitions
	this.load_mc.alphaTo(0,4);
	rej = setInterval(_root,"slider", 7000);	//Start the timer only if the pic has loaded
	priv_mc.swapDepths(_root.getNextHighestDepth());
	debug();
};
image_mcl.addListener(mclListener);
////////////////////////////////////
/////////////////////////////////////// Debug Func ////////////
function debug() {
	var debugbox:Label;
	this.createEmptyMovieClip("debug_mc",this.getNextHighestDepth());
	debug_mc.createObject("Label","debugbox",1000);
	debug_mc.debugbox.autoSize = 1;
	debug_mc.debugbox.text = "rand: "+rand+" oldrand: "+oldrand+" #clips: "+diz;
	debug_mc.slideTo(10,10,0);
	debug_mc.colorTo("0xffffff",0);
	debug_mc.colorTo("0x222222",1,null,2);
}
///////////////////////////////////////////////////////////////
//////// slideshow functions ////////////////
function slider() {
	clearInterval(rej);
	slideshow();
}
function slideshow() {
	clearInterval(rej);
	oldrand=rand;
	rand = randRange(0, numPics-1);
	while (oldrand == rand) {
		rand = randRange(0, numPics-1);
	}
	image_mcl.loadClip(this["file"+rand],this["bg"+rand+"_mc"]); //loadup the last mc
	load_mc.alphaTo(100,1);
	load_mc.swapDepths(_root.getNextHighestDepth());
}
//////////////////////////////////////////////
function transition(type:Number, target:MovieClip) {
	this["bg"+oldrand+"_mc"].alphaTo(0,1);
	drip_mc.cacheAsBitmap = 1;
	drip_mc.swapDepths(_root.getNextHighestDepth());
	var target:MovieClip;
	switch (type) {
		default :
			target._width = Stage.width;
			target._height = Stage.height;
			target._xscale = target._yscale=Math.max(target._xscale, target._yscale);
			target.slideTo((Stage.width/2)-target._width/2,(Stage.height/2)-target._height/2,0);
			target.alphaTo(100,2);
	}
}
//////// Age Check ///////
function agecheck() {
	age_mc._alpha = 0;
	age_mc.slideTo((Stage.width/2),Stage.height/2-age_mc._height/2,0);
	age_mc.alphaTo(100,2);
	load_mc.alphaTo(0,2);
	glow_mc.tween("_height",7,0);
	glow_mc.tween("_width",7,0);
	glow_mc.slideTo(Stage.width,0-7,0);
	glow_mc._y = age_mc._y-14;
	glow_mc.tween("_width",Stage.width,2,"easeOutCubic");
	glow_mc.slideTo(0,null,2,"easeOutCubic");
}
//////////////////////////
////////// Randomizer ///////////
function randRange(min:Number, max:Number):Number {
	var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
	return randomNum;
}

Just so’s you all know, the init():Function is called as soon as you press agree on the website’s intro.

Thanks to anyone who decides they’d like to try helping me,
bb0103 :crying: