-
preloader problems
This preloader is working wonderfully:
Code:
stop();
//AS by Billy T
_root.createEmptyMovieClip('holder1', 1);
holder1._x = 50;
holder1._y = 100;
holder1.loadMovie('images/planet1.jpg');
holder2.loadMovie('images/planet2.jpg');
preloader_mc.onEnterFrame = function() {
l = holder1.getBytesLoaded();
b = holder2.getBytesLoaded();
t = holder1.getBytesTotal();
c = holder2.getBytesTotal();
// all bytes loaded
g = l + b
// all bytes total
h = t + c
p = Math.round((g/h)*100);
if (g<h) {
this.bar_mc._xscale = p;
this._visible = true;
this.percent_txt.text = p+'% loaded';
this.loaded_txt.text = Math.round(g/1000)+'kb loaded';
this.total_txt.text = Math.round(h/1000)+'kb total';
this.ani_mc.gotoAndStop(p);
trace(p)
} else {
// fully loaded
this._visible = false;
}
};
But for whatever reason I am not able to step to the next frame after the images have loaded. If I put this conditional at the end:
Code:
if(p == 100) {
_root.gotoAndPlay(2);
}
the movie seems to simply skip ahead to the next frame instead of working through the preloader first. I also tried to simply put a goto statement inside the else statement with the same result. The trace is showing p successfully incrementing up to 100 like I expect it.
What am I missing?
thanks very much!!
Last edited by arctic; 03-31-2005 at 04:40 PM.
-
the friendly canadian
Hmm... From all I can see, your code is proper.
The only thing that i've ran into in the past is the specific:
Try using something like:
Hope that works... Otherwise, it's beyond my reach.
-
Hey DaVulf. Thanks for the reply. Unfortunately, I tried that one with no difference. This is driving me crazy.
-
Senior Member
The code just keeps on going , even after everything is loaded. This because you use the onEnterFrame. That means the else statement will just keep on repeating eternally.
Either delete the enterFrame when its done or skip the else and make another if.
You also need....
if (g<h && l > 1000) {
... to prevent l and t to be 0 at the same time ( initially ).
-
Hey Pellepiano.
Thanks for your time.
I see the looping of the enterFrame that you are referring to. Problems though.
This:
Code:
} else {
// fully loaded
this._visible = false;
delete this.onEnterFrame;
trace("done")
}
stops the loop, but also prematurely deletes the loader bar before the total bytes of both external images has loaded. Again, back to the original problem, if p doesn't yet equal 100, why would the delete enterframe fire, or any other action that sits in that else statement? Shouldn't it wait until that value has been reached and then execute whatever action is in there?
Sorry for the pain. I appreciate your help.
File enclosed if I made no sense.
http://www.upperhouse.us/preload.zip
Last edited by arctic; 03-31-2005 at 07:35 PM.
-
Senior Member
Why not just skip the else and something like....
if(p == 100) {
delete preloader_mc.onEnterFrame;
_root.gotoAndPlay(2);
}
-
Sweetness!!
It's always the simple stuff.
Thanks again for your help!!
-
the friendly canadian
Glad you found help. Pelle is always there .
I can't believe I didn't notice the onEnterFrame. Oh vell.
Glad it's working!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|