PDA

View Full Version : Loader script suddenly doesn't work anymore?!


kraaft
10-05-2005, 08:33 AM
I use this loader script for practically everything and it's always worked for me until now. I can't see what I've done that would stop it working as it still works fine in other parts of the movie?!

stop();
Stage.align = "LT";
orangeCover._width = Stage.width;
myLoadIncrements = Stage.width/100;
Stage.scaleMode = "noScale";
startLoad();

MovieClip.prototype.startLoad = function() {
holder.loadMovie("andrewPrice.swf");
this.onEnterFrame = function() {
percent = (holder.getBytesLoaded()/holder.getBytesTotal())*100;
myPercent = Math.floor(percent);
if (!isNaN(myPercent)) {
orangeCover._width = Stage.width-(myPercent*myLoadIncrements);
}
if (myPercent == 100) {
trace("d0ne");
holder._alpha = 100;
holder.gotoAndStop(2);
delete this.onEnterFrame; //*****this line?!****
}
}
};

It works fine if i leave off the delete this.onEnterFrame at the end but I don't want the onEnterFrame to continue during the rest of the movie!!
If I include the delete this.onEnterFrame the loading bar(orangeCover) reduces instantly and none of the final code works so the movie doesn't play...

any ideas appreciated....

Berris
10-05-2005, 10:35 AM
Hi
The fact that it works elsewhere in the same program would seem to eliminate generic flaws. My initial workaround would be to create a flag that makes the code only run once. That is:

if (myPercent == 100) {
trace("d0ne");
holder._alpha = 100;
holder.gotoAndStop(2);
// check the flag here first...
if(_root.isLoaded != true){
_root.isLoaded = true; //this code will not run after the first time
delete this.onEnterFrame; //*****this line?!****
}
}


Obviously, you can wrap the flag checking code around as big a chunck of code as you desire.

Hope this helps...

kraaft
10-05-2005, 10:45 AM
Thanks for the info....I just modified oldNewbie's loading script to fit mine and it now works....I'm not sure what the problem was but I addressed all clips as _root.