Preloader help needed please

Hi All,

Can someone plz help me with the following preloader which gives a percentage. I have only 2 weeks experience in flash and would greatly appreciate the help.

I have two scenes on my website 1)preloader 2)movie

I only want to preload up to frame 150 of scene 2 with the percentage showing 100% when all 150 are loaded. The code below loads my whole website all 600 frames.

Thanks and regards,

Greg

preloader
actions for frame 1

  txtPercentage = Math.round((_root.getBytesLoaded()/_root.getBytesTotal())*100) add "% loaded";
  tellTarget ("loader") {
     gotoAndPlay (Math.round((_root.getBytesLoaded()/_root.getBytesTotal())*100));
  }

actions for frame 2
if (_root.getBytesLoaded() == _root.getBytesTotal()) {
nextScene ();
} else {
gotoAndPlay (1);
}

your best bet, if you’re going to use framesLoaded and totalFrames, is to do a test. Check out the band width profiler to see how many bites load by frame 150, out of the total bites, then figure that into the equation. I’ll think about how exactly to go about that… but without looking at your file… it’s impossible for me to be sure.

hello there,

thanks for the reply :slight_smile:

i test movie and its 230000bytes.
Could you please help me change this equation to read 230000bytes rather than total bytes. I have tried to place it everywhere with no success.

Thanks heaps

greg

It depends. Is 230000 the total bites of the movie, or the total bytes at frame 150.

I think that it should be something like this.

actions for frame 1

txtPercentage = Math.round((_root.getBytesLoaded()/230000)*100) add “% loaded”;
tellTarget (“loader”) {
gotoAndPlay (Math.round((_root.getBytesLoaded()/230000)*100));
}

actions for frame 2
if (_root.getBytesLoaded() == 230000) {
nextScene ();
} else {
gotoAndPlay (1);
}

I’m just doing this in my head mind you. I will plug it into flash in the morning and see how this works.

well you have a very good mind.

It works, but once its gets to 100% it keeps going 101%, 120% …

sorry to be a pain, but I really appreciate the help you a giving me. :slight_smile:

Thank again

Greg

Well, I’m not sure about that yet… I’ll work on the problem. In the meanwhile I noticed another error.
actions for frame 1

txtPercentage = Math.round((_root.getBytesLoaded()/230000)*100)+"% loaded";

This should be a “+” sign, not add. Flash 5.0 uses “+” for concate function. Try that out… not that I think it’s going to change your current problem, but it can’t hurt to have the correct syntax.

I’ll keep researching that percent problem.

Thanks for the compliment… sometimes I wonder about my mind. :slight_smile:

I corrected the syntax but it didnt fix it either.
By the way, 230000bytes is up to frame 150

Thanks :slight_smile:

greg

let’s try this…
actions for frame 1

txtPercentage = Math.round((_root.getBytesLoaded()/230000)*100) add “% loaded”;
tellTarget (“loader”) {
gotoAndPlay (Math.round((_root.getBytesLoaded()/230000)*100));
}

actions for frame 2
if (_root.getBytesLoaded()<=230000) {
gotoAndPlay(1);
} else {
gotoAndPlay (“start”);
}

Then, in the first frame of scene two, open your Frame panel and give the flame a name of start.

I have never had any luck getting next and previous scene goto commands to work correctly. In addition to changing that command I’ve reversed the “if else” statement. This may not help that problem, but it’s good programing practice. Put the most common situational in the first place of an “if/else” statement. This way the processor doesn’t have to loop through the whole logic structure most of the time. It only goes on at all, if the conditional in the begining is not met.

Hello,

That works, thanks for all your help and thanks for this great site,

Regards Greg

Greg,
Try actionscripts and their tute on preloaders. I set mine up and it works really cool. It displays the total file size, bytes loaded, bytes left and a percentage all in little cool windows. And, well, it werked for me in a few hours and I am a flashhopper-I just folowed the instructions; here it is in case you wanna take a look. user.mc.net/~dschultz/ just throw in the httpthang in front and no www. I think its pretty cool and it made me feel I am getting somewhere.

pj