Hi there,
First, happy NY everyone.
Secondly, i am stuck with preloading external images. My movie is structered as follows:
1 Two scenes, preload and Scene1
2 The last frame in Scene1 has the name “end”
3 In the preload scene i have
total_bytes = this.getBytesTotal();
loaded_bytes = this.getBytesLoaded();
remaining_bytes = total_bytes-loaded_bytes;
percent_done = int((loaded_bytes/total_bytes)*100);
bar.gotoAndStop(percent_done);
ifFrameLoaded ("Scene 1", "end") {
gotoAndPlay ("Scene 1", 1);
}
4 This is where everything goes wrong; in the first frame of Scene1 i have:
//un - comment for testing purpose
dir = "test";
//dir defines the photo dir comes our param var
//path to photos
//we can make this dynamic by +dir
_global.pathToPics = "test/";
////load the photos in an array
_global.pArray = ["ph_big1.jpg", "ph_big2.jpg", "ph_big3.jpg", "ph_big4.jpg"];
//testing set loaded file equal 0
_global.loadedFile = 0;
MovieClip.prototype.loadPhoto = function () {
// specify the movieclip to load images into
//see array length
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: "+pathToPics + pArray[pIndex]);
trace ("BGCLIP CONTAINER: " + bgTest);
trace ("help me " + bigMov.bg.bgTest);
bigMov.bg["bg_ph" + pIndex].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 : " + this._width);
if (t > 0 && l == t) {
this._visible = 1;
trace ("loaded");
delete this.onEnterFrame;
if (this._width > 1) {
_global.loadedFile++;
if (_global.loadedFile == _global.pArray.length)
{
trace(" Loaded all files...");
root.gotoAndPlay("goHere");
}
}
}
};
loadPhoto ();
stop();
Now when i look at the trace messages the ones that don’t work correctly are the loaded bytes and total bytes. I know for sure that my 4 jpg’s have different byte sizes, but somehow it traces “LOADED BYTES: 12789” and none of my jpg’s has such a bytesize. In fact their bytesizes are: 41, 35, 37, 24 kb.
But the trace PHOTO BEING LOADED does what i thought it would do
PHOTO BEING LOADED: test/ph_big1.jpg
BGCLIP CONTAINER: bg_ph0
......
.....
PHOTO BEING LOADED: test/ph_big2.jpg
BGCLIP CONTAINER: bg_ph1
......
etc
So where in MovieClip.prototype.loadMeter does it go wrong???
Grtz,