-
Yet another preloader issue
My preloader script is supposed to trace the loaded bytes and the total bytes, but it isn't doing it.
What's up? Is it because I am using setInterval?
code:
var loaded:Number = 0;
var getLoaded:Number = 0;
var delay:Number = 0;
this.onLoad = function () {
this.createEmptyMovieClip("holder", 100);
holder._x = 0;
holder._y = 0;
holder._alpha = 0;
delay = setInterval(preload, 10, this.holder);
}
preload = function(mc) {
mc.loadMovie("main_stage.swf");
total = Math.round(mc.getBytesTotal());
getLoaded = Math.round(mc.getBytesLoaded());
trace("total = "+getLoaded);
mc._alpha = 0
if(total< getLoaded) {
trace("loaded = "+ getLoaded);
}else{
trace("total = "+getLoaded);
trace(mc + " loaded!");
mc._alpha = 100;
clearInterval(delay);
}
}
-
Senior Member
What exactly are you trying to do? Your code is loading the same movie every 10 ms over and over again. If you are trying to make a preloader, put the loadMovie() code outside the preload function and only use setInterval() to check whether or not the movie has been loaded.
-
Re:
Okay,
I just want to be able to recycle the preloader so that it can load different .swf's on the fly, that's why I put the loadMovie function in the code
Can you give an example of what to do please?
-
Senior Member
You only want to load a movie once right? So put that code outside of the loop. Something like this:code: var loaded:Number = 0;
var getLoaded:Number = 0;
var delay:Number = 0;
this.onLoad = function () {
this.createEmptyMovieClip("holder", 100);
holder._x = 0;
holder._y = 0;
holder._alpha = 0;
holder.loadMovie("main_stage.swf");
delay = setInterval(preload, 10, this.holder);
}
preload = function(mc) {
total = Math.round(mc.getBytesTotal());
getLoaded = Math.round(mc.getBytesLoaded());
trace("total = "+getLoaded);
mc._alpha = 0
if(total< getLoaded) {
trace("loaded = "+ getLoaded);
}else{
trace("total = "+getLoaded);
trace(mc + " loaded!");
mc._alpha = 100;
clearInterval(delay);
}
}
-
Re:
Thanks, for that.
My problem though is that I can't get the code to trace the bytes loaded when I simulate a download. Ultimately, I want this to be used in a percentage bar.
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
|