Hi there,

Haven't been working with Flash much since Flash5. Now I'm starting all over in MX2004 and I can't get things to work.

Here's the plan:

I've got a php script that reads a directory and returns the total of images; the image names (img0 = bababa.jpg); and the directory in which they are located.

I want to create a photoalbum in which I dynamically load these jpgs one at the time. I was thinking to create a holder for each jpg and then set the visibility of the others to 0 or swap depths. Another solution ofcourse is to load a different jpg in the same holder clip.

Well here is the script I've managed to script/copy/paste together:

Code:
var mainTimeline = this;

varSender = new LoadVars();
varSender.cacheKiller = new Date().getTime();

varReceiver = new LoadVars();
varReceiver.onLoad = function (success) 
{
  if (success)
  	{
    	mainTimeline.cc_status.text += (this.total);
        // this.total is a variable reveived thru the php file
	} else {
		//clearInterval(varPreloader);
	    mainTimeline.cc_status.text = "load failed!"
	}
}
//varPreloader = setInterval(checkVarStatus,100);

function checkVarStatus () {
  var kbLoaded = Math.floor(varReceiver.getBytesLoaded()/1024);
  var kbTotal = Math.floor(varReceiver.getBytesTotal()/1024);
  if (kbTotal == undefined)
  	{
    kbTotal = "???";
  	}
  mainTimeline.cc_status.text = kbLoaded + " / " + kbTotal + "Kb";
}

varSender.loaddirectory = "commissions";
varSender.sendAndLoad("http://localhost/pruigrok/load.php", varReceiver, "POST");

/////////// start jpg load //////////

MovieClip.prototype.loadjpg = function(picName, holderName)
{
	var h = holderName==undefined ? "holder" : holderName;
	this.createEmptyMovieClip(h, 1);
	this._visible = false;
	this[h].loadMovie(picName);
	this.onEnterFrame = function()
		{
			if (this[h]._width > 0)
				{
					this._alpha = 99;
					//delete this.onEnterFrame;
					this._visible = true;
					this.onComplete();
				}
			else
				{
					this.onLoading();
				}
		}
};
x = this.createEmptyMovieClip("xxx",1);

x.onLoading = function()
	{
		if(this.hhh.getBytesLoaded())
		{
		this._parent.cc_status.text = Math.round(this.hhh.getBytesLoaded()/this.hhh.getBytesTotal()*100)+"%";
		}
	}

x.onComplete = function()
	{
		this._parent.cc_status.text = Math.round(this.hhh.getBytesLoaded()/this.hhh.getBytesTotal()*100)+"%";
		this._x = 100;
		this._y = 100;
	};

datum = new Date();
var count = 0;

function CC_loadJPG()
	{
		if(count+1<=varReceiver.total)
			{
			x.loadjpg("http://localhost/"+varReceiver.imgfolder+varReceiver["img"+count]+'?'+datum.getTime(), 'jpg'+count);
//varReceiver.imgfolder and varReceiver.img0 thru varReceiver.img10 are received thru the php file
			count++;
			}
	}
stop();
I placed it in a frame of the main timeline. So the script automatically loads the vars onenterframe. Then on click I call the CC_loadJPG function which loads a jpg.

I think it's the best solution to load the jpgs in different holder clips. But how would I do this? And still have the loading status work? And how would I best hide the other holder mc's when the new jpg is loaded?

Any hints?

Cheers,
Gekke_Hollander