PDA

View Full Version : loading wrong?


utswim
11-01-2002, 03:04 PM
I'm making a preloader MC (tweened progress bar) for a single-scene SWF. The MC is on frames 1 and 2, following the Intermediate Level Tutorial 05. This tutorial is for Flash 5. I'm working in MX, am I missing something?

The code for frame 1 is as follows:

total = _root.getBytesTotal();
loaded = _root.getBytesLoaded();
remaining = total-loaded;
percent = int((loaded/total)*100);
loadBar.gotoAndStop(percent);
ifFrameLoaded (17) {
gotoAndstop (3);
}

I have a gotoAndPlay(1); as code in frame 2. When I test the movie, I just get a black screen, and frame 3 has a bunch of buttons, pics, etc. on it, including a stop(); action. Any suggestions?

-Thanks.

GWiNet
11-01-2002, 03:44 PM
your syntax is wrong, specifiacally here:ifFrameLoaded (17) { that should be:if(loaded >= total){orif(loaded >= 17){

utswim
11-01-2002, 03:52 PM
I changed it to the first one, if(loaded >= total) {
I think you're second example confuses bytes and frames. Anyway, the first makes more sense, but it still doesn't work.

I found that when I removed the code completely from the first frame and tested it, at least the right screen came up, although it looped my progress bar.

What do you think?

GWiNet
11-01-2002, 04:19 PM
yeah, you're right, the 2nd code does confuse frames and bytes. use bytes - its more precise. so, you can either preload the whole thing - ie if loaded >= total, or you can figure out how much you want to preload in bytes (you can assume 60% or so), and check the value of percent.

as for the looping, if you don't have a conditional, it will obviuosly loop continuously.

utswim
11-01-2002, 04:40 PM
It only loops when I delete the whole thing. I'm trying to make it work using this code, and it doesn't:

total = _root.getBytesTotal();
loaded = _root.getBytesLoaded();
remaining = total-loaded;
percent = int((loaded/total)*100);
loadBar.gotoAndStop(percent);
if(loaded >= total) {
gotoAndstop (3);
}

I can't figure out why it returns a black screen instead of frames 1 or 3. There's no black frames in the entire movie.