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: