I have a problem with my preloader script.When I am previewing single swf file by itself, it works fine, but my site is set up from several swf files that load in to movie clips and preloader doesn’t show up right when one swf file is loaded into another.
Preloader itself consits of the graphic, text that says “loading” and dynamic text showing bytes loaded. When one swf file gets loaded into main.swf, preloader of the loaded swf file doesn’t show up properly. It only shows animation graphic, but none of the text is visible.
This is the script that I have inside preloader mc on the first frame inside the preloader mc frame:
lastFrame = 1;
function loadedIndicatorFrame() {
var newFrame = int((_parent.getBytesLoaded() / _parent.getBytesTotal()) * 65) + 2;
if (newFrame - lastFrame > 4) { //too far
lastFrame += 4;
loadedText = int(_parent.getBytesTotal() / 1024 * (lastFrame - 2) / 65) + "kb of " + int(_parent.getBytesTotal() / 1024) + "kb";
} else if (newFrame - lastFrame > 0) { //normal move
lastFrame++;
loadedText = int(_parent.getBytesLoaded() / 1024) + "kb of " + int(_parent.getBytesTotal() / 1024) + "kb";
} else { //update the text only
loadedText = int(_parent.getBytesLoaded() / 1024) + "kb of " + int(_parent.getBytesTotal() / 1024) + "kb";
}
return lastFrame;
}
And this is the code I have attached to the preloader mc on the main stage:
onClipEvent (load) {
if (_parent.getBytesTotal() == _parent.getBytesLoaded()) {
quickPlay = true;
} else {
preLoad = (_parent.getBytesTotal() * 0.75); //percent to preload
}
_parent.stop();
}
onClipEvent (enterFrame) {
gotoAndStop(loadedIndicatorFrame());
if (quickPlay == true) { //quickly play the anim
if (_currentframe == _totalframes) {
_parent.play();
}
} else { //wait for the preload
if (_parent.getBytesLoaded() >= preLoad) {
_parent.play();
}
}
}
I am not sure, but my problem might be with _parent. references in the code. I really don’t know if that’s the case or what should be changed. Can someone help me out to figure this out? It would be greatly appreciated.
thanks