PDA

View Full Version : preloader progress bar


Billy T
12-05-2001, 01:44 AM
Can someone please tell me why this progress bar isnt working?

I have an instance name ProgressBar and in the preloader script I have

_root.ProgressBar.gotoAndStop = Percentage;

My ProgressBar is a 100 frame animation and I want it to move to the frame number that is the Percent variable (I know the percent variable is working because the text box which displays it is working fine).

Any help would be greatly appreciated

TIA

Taldos
12-05-2001, 02:13 AM
_root.ProgressBar.gotoAndStop(Percentage);

the number has to be within the parentheses or else the goto function won't work. hope this makes sense and helps. it should work provided you have previously declared percentage.

thanx and be well
Mwamufiya Edward

Billy T
12-05-2001, 02:18 AM
thanks for your help but it still isnt working.

Did you put that in the file that I upped and it worked?

Thanks again

Taldos
12-05-2001, 02:31 AM
ya that is what i thought inside u code at the top


onClipEvent (load) {
StartTime = getTimer();
}
onClipEvent (enterFrame) {
HERE: Change the "<" sign to "<="
//for some reason flash has been giving me trouble
//with this as well. i think that should be it
//anywasy let me know
if (_root.getBytesLoaded() < _root.getBytesTotal()) {
Total = _root.getBytesTotal()/1000;
Received = _root.getBytesLoaded()/1000;
Percentage = (Received/Total)*100;
Speed = Received/((getTimer()-StartTime)/1000);
Remaining = (Total-Received)/Speed;
_root.PercentText = int(Percentage) add "%";
_root.AmountText = int(Received) add "K / " add int(Total) add "K";
_root.TimerText = int(Remaining) add " seconds remaining";
_root.ProgressBar.gotoAndStop = Percentage;
} else {
_root.play();
}
}

Billy T
12-05-2001, 02:38 AM
but now when it gets to 100% it just stops because the else statement never gets called.

Also, with the progress bar it is still not playing the animation but I noticed when it got to 100% it did jump to frame 100 - it just didn't play the frames 1-99...

strange...

Thanks again:p

Taldos
12-05-2001, 02:48 AM
if u r trying this on ur machine it would not show the progress as the image is already on your machine, there fore loading time is non existant, i would recomend putting up on a server and then trying it out. then it should work. once again if the picture is on your own desktop there should be no laoding time and therfore it should just jump to 100%.

i am pretty sure that is what the problem is.

thanx and be well
Mwamufiya Edward

Billy T
12-05-2001, 02:59 AM
I dont think that is the problem as I am going "view streaming" whenever I test the movie.

you can see what happens when I use the <= operator here

http://users.bigpond.net.au/cab/timeframe/main.html

when I use just the < it works fine but doesnt play the progress bar

Thanks again

Taldos
12-05-2001, 03:26 AM
got it working. send me ur email so that i can just email u the file, i don't have pc so i can't zip the file. long story short i took out the shape animation you had and replaced the simple grapic with a movie Clip now i can see the progress bar actually moving.

Kool i was just abou to start on my own preloader, this was good practice

Billy T
12-05-2001, 03:31 AM
;)

thanks man

billyt@bigpond.net.au

btw you can get zipit for mac

Thanks again

Taldos
12-05-2001, 04:39 AM
don't know if u will get this. but if u change the gotoAndStop(Percentage) to

gotoAndStop(int(Percentage)); it flows a lot nicer

hugo
12-06-2001, 03:01 AM
Billy T,

saw your question but never saw the right answer.
Here's complete code which is working without changing anything in your movie. Good luck!

onClipEvent (load) {
StartTime = getTimer();
}
onClipEvent (enterFrame) {

if (_root.getBytesLoaded()<_root.getBytesTotal()) {
Total = _root.getBytesTotal()/1000;
Received = _root.getBytesLoaded()/1000;
Percentage = Math.floor((Received/Total)*100);
Speed = Received/((getTimer()-StartTime)/1000);
Remaining = Math.floor((Total-Received)/Speed);
_root.PercentText = int(Percentage) add "%";
_root.AmountText = int(Received) add "K / "add int(Total) add "K";
_root.TimerText = int(Remaining) add " seconds remaining";
_root.progressbar.gotoAndStop(Percentage);
} else {
_root.play();
}
}

Billy T
12-06-2001, 03:42 PM
nice one thanks man :)

so what did you change in the script?

cheers

hugo
12-07-2001, 01:59 AM
Hey Billy T,

if you look at the following lines

Percentage = Math.floor((Received/Total)*100);
Speed = Received/((getTimer()-StartTime)/1000);
Remaining = Math.floor((Total-Received)/Speed);

you will see Math.floor, which rounds up a number with decimal places to a whole number, thus giver Flash a number of th frame to go to. (ex. 5 and not 5.345). Otherwise Flash keeps looking for
a frame like 5.345 and can't find it.

Use this function wherever u can to round up numbers. Good luck and let me know if you have any more questions. Cheers!

Billy T
12-07-2001, 02:02 AM
ahhh ok I see

so is that the same as using

Percentage = int((Received/Total)*100);

??

Thanks again

hugo
12-07-2001, 02:04 AM
Yeah, it is. I just prefer MAth function better.

Cheers!

Billy T
12-07-2001, 02:06 AM
cool

Thanks champ