I need to make sure all jpg's has been loaded before the movie plays?

HI,

I have a couple of jpg’s loaded dynamicly, everthing works local. But when i put this online the movie is already playing while the jpg’s aren’t loaded yet.

So i need to make sure all jpg’s has been loaded before the movie plays (it’s a movie that uses the jpg’s as a mask and background )

How would i do this?

Thnks in advanced

Preloaders. Search the forum a bit, I’m sure you’ll be able to find something :slight_smile:

thnks, ilyas

I browsing/looking at http://www.kirupaforum.com/forums/showthread.php?s=&threadid=15472&perpage=15&pagenumber=1

in another window.

but what i have found is that the jpg preloader is shown when a button is pressed or something like that.

Want i want is to use the preloader i have for my main movie. During this preload-scene all the dynamic jpg’s must have been loaded. I have to make sure everything is loaded before starting the movie. In another words i don’t want to display a preloader for each jpg.

So i was thinking to use the first frame in the main movie and make AS that loads the jpg’s, something like:


bigMov.bg.bg_ph1.loadMovie (pathToPics + pArray[3]);
bigMov.bg.bg_ph2.loadMovie ( pathToPics + pArray[0]);
bigMov.bg.bg_ph3.loadMovie ( pathToPics + pArray[1]);
bigMov.bg.bg_ph4.loadMovie ( pathToPics + pArray[2]);

But just the first jpg is shown (so just this one is loaded i think),
so i need to make sure everything is loaded before continuing.

I saw your code snippet and i want to adjust it a little bit,


for (i=1; i<5; i++) {
bg.onEnterFrame=function(){
  var l="bg_ph" + i.getBytesLoaded();
  var t="bg_ph" +i.getBytesTotal();
  if (l > 0 && l >= t){
    "bg_ph" +i._visible=1;
    delete this.onEnterFrame;
  }
  else {
    // stuff with your loading bar
  //i don't want to use this part or i dn't think i need to use this part
  }
}

Does this make any sense??

Code is not valid, these one is but doesn’t do the job.


for (i=1; i<5; i++) {
bigMov.bg.onEnterFrame=function(){
  var l=["bg_ph"+ i].getBytesLoaded();
  var t=["bg_ph" +i].getBytesTotal();
  if (l > 0 && l >= t){
    ["bg_ph" +i]._visible=1;
    delete this.onEnterFrame;
  }
  else {
    // stuff with your loading bar
  //i don't want to use this part or i dn't think i need to use this part
  }
}
}

Hmm,

Not very sharp today


for (i=1; i<5; i++) {
//now load each jpg into a container nested in bigMov as mask and as bg
bigMov.bg["bg_ph"+i].loadMovie (pathToPics + pArray[3]);
bigMov.bg["bg_ph"+i].loadMovie ( pathToPics + pArray[0]);
bigMov.bg["bg_ph"+i].loadMovie ( pathToPics + pArray[1]);
bigMov.bg["bg_ph"+i].loadMovie ( pathToPics + pArray[2]);
bigMov.bg.onEnterFrame=function(){
  var l=["bg_ph"+ i].getBytesLoaded();
  var t=["bg_ph" +i].getBytesTotal();
  if (l > 0 && l >= t){
    ["bg_ph" +i]._visible=1;
    delete this.onEnterFrame;
  }
  else {
    // stuff with your loading bar
  //i don't want to use this part or i dn't think i need to use this part
  }
}
}

So now i tried


////load the photos in an array
_global.pArray = ["ph_big1.jpg", "ph_big2.jpg", "ph_big3.jpg", "ph_big4.jpg","ph_sm1.jpg","ph_sm2.jpg","ph_sm3.jpg","ph_sm4.jpg"];
MovieClip.prototype.loadPhoto = function() {
	// specify the movieclip to load images into
	//------------------------------------------
	for (i=0; i<4; i++) {
		this.pIndex = i;
		trace (pIndex);
	bigMov.bg["bg_ph" + pIndex].loadMovie(pathToPics+pArray[pIndex]);
	bigMov.bg["bg_ph" + pIndex].onEnterFrame = loadMeter();

	}
};
MovieClip.prototype.loadMeter = function() {
	var pIndex, l, t;
	l = this.getBytesLoaded();
	t = this.getBytesTotal();
	if (t>0 && t == l) {
		trace("loaded");
	} else {
		trace(l/t);
	}
};
loadPhoto();

It looks like all the jpg’s are being loaded. But somehow i can just see the first one.

I got a movieClip(“bg”) that holds 4 containers each on a frame with a stop action named bg_ph0, bg_ph1 etc up to 3.

The problem with your previous codes is that you’re overwritting the onEnterFrame each time you get into the loop so you end up preloading the last frame only.

You could set up a loading in chain. I think I posted something (completely bugged) one day, I’ll try and find it…

Hmm,

I hope you can find it. I am really stuck, i think i know the main thing. RRRRrrrrrrrrrrr

yes i could use some help here.

This is what i have so far and yes i need to look at the onEnterFrame issue


//un - comment for testing purpose
dir = "test";
//dir defines the photo dir comes our param var
//path to photos
_global.pathToPics = +dir + "/";
////load the photos in an array
_global.pArray = ["ph_big1.jpg", "ph_big2.jpg", "ph_big3.jpg", "ph_big4.jpg"];
_global.loadedFile = 0;
MovieClip.prototype.loadPhoto = function () {
	// specify the movieclip to load images into
	//------------------------------------------
	for (i = 0; i < 4; i++) {
		pIndex = i;
		trace ("pIndex = " + pIndex);
		bgTest = "bg_ph" + pIndex;
		bigMov.bg["bg_ph" + pIndex].loadMovie (pathToPics + pArray[pIndex]);
		trace ("PHOTO BEING LOADED: " + pArray[pIndex]);
		trace ("BGCLIP CONTAINER:  " + bgTest);
		trace ("help me " + bigMov.bg.bgTest);
		bgTest.onEnterFrame = loadMeter ();
	}
};
MovieClip.prototype.loadMeter = function () {
	var l, t;
	l = this.getBytesLoaded ();
	trace ("LOADED BYTES: " + l);
	t = this.getBytesTotal ();
	trace ("TOTAL BYTES: " + t);
	trace ("this width: " + this._width);
	if (t > 0 && l == t) {
		this._visible = 1;
		delete this.onEnterFrame;
		if (this._width > 1) {
			_global.loadedFile++;
			trace ("Number " +loadedFile);
		}
		if (_global.loadedFile == _global.pArray.length) {
			trace ("	Loaded all files...");
			_level0.gotoAndPlay ("goHere");
		}
	}
};
loadPhoto ();
stop ();


Hi,

Really stuck here>

anyone ?? Tutorials., tips??