Preloader Problem

how do i make a preloader with a bar that shows load progress?

Take a look at my tutorial on “Preloaders rererevisited” at www.centerspin.com

www.FLASHKIT.com

ok…david…i used “The animated graphic display of preloader information” and it stops around 75% when i go to the page. (http://mywebpages.comcast.net/photos.html)
do you think you know what it could be?

the load bar didn’t exactly work i’m not sure what i did wrong…but this is it: My Load Bar

I just loaded it up and it did the correct thing. It started out at 0% and loaded all the way to 100%, then the page came up. I was able to Navigate etc.

I’m not sure what could be the problem with viewing it from your machine. What’s your connection speed?

i’m running cable…i figured it out though.
in the actionscript:
totalK = getBytesTotal()/1000;
loadedK = getBytesLoaded()/1000;
remainingK = totalK-loadedK;
percentageK = (loadedK/totalK)*100;
setProperty (“bar”, _xscale, percentageK);
if (loadedK>=totalK && totalk != 0) {
[COLOR=blue]gotoAndPlay (6);[/COLOR]
}
in that last line i had one of my frames labeled “pics” and i had the line as [COLOR=blue]gotoAndPlay (pics);[/COLOR].
i guess when it tried to load that frame label it would stop because there are two scenes and both scenes had that frame labeled as pics.
so i simply changed that and it worked.

oh, yeah… frame labels definitely need to be unique. It goes deep too. If you’re running say one swf in level0 _root. and you load up another outside swf into either level1+ or into a movie clip instance in the _root, it still needs it’s own unique frame, and instance handles. They are all considered to be part of a single movie, single timeline in that regard.

I have a loop to throw you now. I worked out my ultimate preloader, and it seems to be working ok. I’d like some people to test it out so that I can see how it will work in various situations and productions.

Below are the details behind it, and the location of the FLA for download. Anyone who wants to take a look is welcome to.

(Keep in mind… I might change this some more. I was just introduced to another preloader that I had not seen before. I have yet to explore it’s intricasies(sp?). Likewise, one never knows when one of my fellow Flashers will improve upon something that I do. It happens all the time. On with the show.)

The download is located at

http://www.centerspin.com/download/preloadWEstTmRemain.fla

The preloader works like this.

First thing to note is that it’s small. Only 100 by 100, I think. If one were to use it in a larger, or smaller format, the easiest way would be to attach this script to the “plc” (pre loader clip)

onClipEvent(load){
_yscale=200;
_xscale=200;
}

In the first image we see the first frame of the “plc”, and we see a blank square of white on the stage. This square is meant is a place holder more than anything else. You can change the color, or whatever you want.

The first frame top layer of the “plc” contains a _root.stop(); command to stop the main timeline. Then it sets a variable equal to the timer();. Thanks to suprabeener for that one.

Frame 2 is the real meat and potato’s of the clip. It has two text fields (tkoutput, and remainingTime, and a movie clip of a red bar 50 pixels tall and 5 wide with an instance name of “bar”

The script

// grab variables for this pass
totalK=_root.getBytesTotal()/1024;
loadedK=_root.getBytesLoaded()/1024;
//change one to output. plc doesn’t seem to work if we floor the
//above two variables, so I just do this one for output to the
//textfield
tkoutput=Math.floor(totalK);
remainingK=totalK-loadedK;
percentageK=(loadedK/totalK)100;
//set the bar size
bar._yscale=percentageK;
//get elapsed time since start of preload
elapsedTime=getTimer()-sTime;
//find remainging time. Thanks to suprabeener
remainingTime=Math.floor((elapsedTime
(totalK/loadedK)-elapsedTime)/1000;
//break?
if (percentageK==100&&totalK!=0){
_root.gotoAndPlay(2);
}

Frame 3 is just a loop back to frame 2 of the “plc”.

The “plc” is optimized to be as little k as I can get it. It runs very small and very fast.

It offers the viewer the absolute bare information that he would need to know. What’s the total k to download, how much has downloaded (graphical bar display) and how many seconds more he has to wait.

I’ve noticed that sometimes preloaders have a tendency to not work right. I think everyone knows this. This particular preloader is designed with the following in mind.

In publish settings, under the Flash tab, there is an option to load from top down, or from bottem up. This is the load of the layers in the movie. This clip requires that the swf be published in top down load order. In order for this to work right, the absolute top layer, first frame of your movie must be the preloader clip and there should be nothing in that frame on any layer other than the preloader. If you add a game to that frame for play during preload, make sure it is in a layer below the plc. It must load before anything else. Likewise the preloader clip has for it’s very first action, a stop(); to the main timeline. You can’t change the layer stack above the a/s layer and have this work correctly.