Preloading Of A Site

hey pplz… i have a problem…

i have maid a flash site… the swf is 3.5 megs and i have put it into html… which is 1kb … and i have uploaded them to geocities.com… on the web neither will load… the flash has a preloader and yet… nothing…

plz help me… tell me where i went wrong and how i can fix my problem

any replies or ideas r apriciated!!!

thnx=)

Hey there,

I’m going to give this a shot and see if I can help you out.

There’s a couple things you need to make sure of: Are both your files actually loaded on the server? A good way to check is manually typing in the address to each file and see if you get anything back.

Assuming both are on the web and it’s the preloader that isn’t working, here’s one that I made up a little while ago. I doubt it’s the best way, but it does work:

loadedbytes = getBytesLoaded();
totalbytes = getBytesTotal();
loadedkbytes = Math.ceil(loadedbytes/1000);
totalkbytes = Math.ceil(totalbytes/1000);
if (loadedbytes == totalbytes) {
gotoAndPlay (“main”, 1);
}
frame = int(loadedbytes/(totalbytes/100));
tellTarget (_root.loader) {
gotoAndStop (_root.frame);
}

This code assumes you have a scene called “main” (I separated my preloader and main scenes for your info). The second part which is the tellTarget (_root.loader)… that’s just for the actual animation I have while it loads. So you can change _root.loader to whatever instance name you give your animation… or you can probably just delete it (I don’t think it’s vital).

Ok… I think that should cover it… let me know how that works,

Uth

Sorry I forgot to ask this in my first post:

Why is your site 3.5 megs? :stuck_out_tongue: That’s a hurtin’ download lemme tell ya.

Laters,

Uth

thnx… but im a flash neutral and im not really good wid advanced action script… so i was wondering u could explaing to me this action script u gave me… and where i should insert it…

i understand that it seems that im pretty dumb… but if could help me out… i would really thank u for ur time (dont think its possible to do more online)… :slight_smile:

thnx…

any other suggestions are also welcome!

Hey there,

It’s definately not a problem to explain it more carefully (that’s probably what i should have done in the first place).

Ok… first to explain the code I gave:

loadedbytes = getBytesLoaded();
// this checks how many bytes of your site have been loaded (downloaded) thus far

totalbytes = getBytesTotal();
//this checks what the total size of your movie is (in bytes)

loadedkbytes = Math.ceil(loadedbytes/1000);
totalkbytes = Math.ceil(totalbytes/1000);
//these two variables only change the information from bytes into <b> kilo</b>bytes. Basically making the information into K.

if (loadedbytes == totalbytes) {
gotoAndPlay (“main”, 1);
}

//this says if the amount of loaded information is equal to the total amount there is (aka… you’ve downloaded the whole thing), then go to a scene called main, at the first frame.

frame = int(loadedbytes/(totalbytes/100));
tellTarget (_root.loader) {
gotoAndStop (_root.frame);
}

//this code was specific to my file. I had an animation that ran during the preloader… so the users wouldn’t get board waiting for your movie. It basically says that get an integer (or whole number… no decimals) value from dividing totalbytes by 100, and use that sum to divide into loaded bytes (or in other words, this makes a percentage). Because my preloader was only 100 frames, this makes it stop at a percentage. Afterwards it tells my preloader movie to gotoandStop at the percentage (or frame between 1 & 100).

Ok I think that was pretty detailed, and should give you a good idea of what’s going on.

So… to makes this work you insert that code I pasted above into frame 1 of a scene called preloader. On frame 2, you put in the actionscript of :

gotoAndPlay(1);

This makes it so that all your code in frame one gets check (and your preloader updated, then on frame 2 it tells it go back and play frame one again. So it just repeats and repeats while updating your preloader.

Just make sure that your main content (everything that’s supposed to come after the preloader) is in a scene called “Main” (no quotes).

Well… I think that’s covers pretty much every single point.

I hope that helps you a bit, and don’t ever worry about asking for more help if you don’t understand… that’s the whole point of a help forum.

Cheers,

Uth =)

i made a preloader… it’s 2 frames… and in the 1st frames i put in ure action scrypt… and i also made the preloading movie clip called root… i changed the action script a little to match my preloader… in the line:

frame = int(loadedbytes/(totalbytes/100));

this is how i changed it:
frame = int(loadedbytes/(totalbytes/2));

since my preloader is only 2 frames… instead of 100… i put in 2… i hope that was a right move…

anywayz… when i finished… i tried to preview the movie… while loading… flash sent me a message that the script in that movie is too heavy and it makes flash (MX) run slowly… and that if i continue… my computer may become inresponsive… i continued… no matter how many time i was getting that msg all over again… i put the flash file up on the web anyway…

http://us.share.geocities.com/csclandaa/daa.swf

… check it out… maybe itll load for you or other ppl

:frowning: but the problem remains

i published the site… otherwise iwouldnt be able to upload it… butr anywayz… i tried running the published version on my harddrive… same msg appears bout heavy script…

may be if u had msn messenger… i could send u the rought draft… the fla file… so u could taker a look at it…

frame = int(loadedbytes/(totalbytes/2));

Since that part is referring to the movieclip that runs while your animation loads, you’d only want it at 2 if your movieclip is 2 frames long.

I had 100 in there because my preloading <b> animation</b> is 100 frames long, not my preloader itself. So I guess it depends what you are trying to show while your site preloads…

I know my code works perfectly with Flash 5, as to mx… you’d have to ask somebody else because I don’t use it. I’m guessing it probably shouldn’t make a difference but I couldn’t say for sure.

As to your file becoming unresponsive… that’s probably because there are a few errors in there. At least that’s a guess anyways.

Laters,

Uth

i have installed flash 5 and deleted flash mx… used your code… and then published the movie… same note appears:

the script in this movie appears to be too heavy, continueing may result in you computer becomming inresponsive…

i think i may be using the code wrong… ur animation for the preloader… was it a movie clip? mine is … i called it “root” to match the action script… it is 2 frames long… thats why i changed the script… my preloader scene is also 2 frames long… im very confused and time is pressing and im out of ideas… i was thinking… do u have icq? msn or something… i could send u the .fla file for u to look at it and maybe even edit…

thnx… plz reply soon!

Try this, its much easier if your adding it to a big site.

Step 1:
Create a movieclip, don’t place anything in it.

Step 2: Create a dynamic text field give it a variable name of process, create a movieclip that has a bar like image and name it preloader.(Remember the creating a bar movieclip is only necessary if you want to have a bar to show the progress of the movie, otherwise just create a dynamic text field.)

Step 3:
Drag the empty movieclip on to your main timeline, select it, and open the actions panel and place this code:

onClipEvent (enterFrame) {
if (_root.getBytesLoaded() > 0 && _root.getBytesLoaded() == _root.getBytesTotal()) {
_root.gotoAndStop(“beginMovie”);
} else {
load_bytes = _root.getBytesLoaded();
total_bytes = _root.getBytesTotal();
percent = int(load_bytes/total_bytes * 100);
percentoutput = int(load_bytes/total_bytes * 100);
_root.preloader._xscale = percent;
_root.process = percentoutput + “%”;
}
}

The great thing about this code is one, its portable and two it only requires one frame because it automatically loops itself.

Hope this helps.

Kyle
:slight_smile:

Hey,

Well I do have icq and msn, but I don’t use them often. If you’re really stuck, and iceman’s solution doesn’t work for you, go ahead and send it. 31821463 and [email protected] (for msn).

or just zip it and email it to me (at [email protected] )

Have a good one,

Uth:nerd:

P.S - Interesting solution Iceman :slight_smile: