PDA

View Full Version : Help with broken preloader



Sammo
December 1st, 2004, 04:57 PM
I can never seem to get preloaders working....

This is one attempt that im quite certain I want to work, but me and a friend can't work out why the smeg it's not working...


stop();

total = getBytesTotal();
done = getBytesLoaded();
percent = loader/total*100;

if (total == done) {
gotoAndPlay(3);
} else {
_root.load_square._width = percent*5.5;
/*whatever number is needed to times 100 to equal to stage width*/
_root.load_square._height = percent*4;
/*whatever number is needed to times 100 to equal to stage height*/
gotoAndPlay(1);
}

Thats the code on frame 1, frame 3 is some music (so i cant post the fla for copyright (and size) reasons).
There is a movieclip called load_square which is a 1pixel sqaure that is in the center of the stage, it's meant to get bigger and will fill the stage up when its fully loaded.

When it's run, the square doesnt grow, but when the movie is loaded it does go onto play the music.
I have tryed _yscale and _xscale as well, that doesnt work either, and my friend came up with this:


stop();
bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
this.load_sqaure._width = getPercent*550;
this.load_sqaure._height = getPercent*400;
if (bytes_loaded == bytes_total) {
this.gotoAndPlay(3);
}

Which does nothing at all...


Can anyone help me? I can't see whats going wrong at all...

mikkomikko
December 1st, 2004, 06:05 PM
Put this on frame 1:


total = getBytesTotal();
done = getBytesLoaded();
percent = done/total*100;
if (total == done) {
gotoAndPlay(3);
} else {
_root.load_square._width = percent*5.5;
/*whatever number is needed to times 100 to equal to stage width*/
_root.load_square._height = percent*4;
/*whatever number is needed to times 100 to equal to stage height*/
}

and


gotoAndPlay(1);

on frame 2.

Your first script was ok, except percent = loader/total*100;

rhamej
December 1st, 2004, 06:13 PM
Shouldn't this
percent = loader/total*100;

Be this?
percent = done/total*100;

Sammo
December 2nd, 2004, 02:32 AM
****....

I'm so stupid....

Thanks guys

Sammo
December 2nd, 2004, 11:57 AM
ARGH

I've done exactly what mikkomikko said to do and it still doesnt work! :scream:

I'll upload the fla (without the music) can anyone please help me?

Sammo
December 20th, 2004, 08:09 AM
FIXED IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!111111111 1111


Didn't set the load_square to have an instance name http://kirupaforum.com/forums/images/smilies/depressed.gif