Simple Preloader with one movie loaded to level

If you want a bar, define a rectangle movie in its maximum size and give it the instancename "bar". frame 1: // load the additional swf to level 1 loadMovieNum("myMovie.swf",1); frame 2: // nothing in here frame 3: // get the bytes loaded so far or 0 if we didn't start loading yet actBytes = _level1.getBytesLoaded() || 0; // get the total bytes to load or 100 if we didn't start loading yet totBytes = _level1.getBytesTotal() || 100; // calculate a percentage value of the bytes loaded percent = Math.round(actBytes * 100 / totBytes); // if there are more bytes to load if( totBytes - actBytes > 10){ // if you don't want a bar, delete the following line bar._xscale = percent; // go back to the loop gotoAndPlay(2) } frame 4: // ready, go
Jack Date: 08/07/2001

Since I am new to this, can you explain in greater detail what happens here.
Minh Date: 11/08/2001

frist frame tells flash to load the movie into flash. Second frame is nothing, no actions. Third frame tells it to create a varible call actBytes which tell how much byte it has loaded. totByte tells how much bytes the movie cost. percent is simple mathametics, byte being loaded times 100 and divided by totals byte equals precent. You can figure out the rest :)
Date: 16/10/2001

I don\'t understand why looping WHILE totbytes-actbytes<10... It makes no logic to me.. It means if the difference between loaded bytes and total bytes is less than 10 the movie is not loaded... if it\' MORE, itIS loaded... How can that work correct!?
===> absolutely correct, my fault, corrected it :) (bokel)
leo Date: 03/11/2001

How can I test a preloader effectively from my desktop. There is usually no wait time.
===> your preloader won't work from your local harddisk. the only way to test it, is to load the swf from a webserver. for testing purposes you can install a webserver like xitami or apache localy. (bokel)
geo Date: 18/11/2001
How can I test my preloader from the HD. There is usually no waiting time.. >>While running your test from the HD you can go into the \'Debug\' menu and set the desired simulated bandwidth, e.g. 56K or a custom setting. Then go into the \'View\' menu and set it to \'Show Streaming\' Your file will then run from the beginning, limiting the loading rate to simulate the \'live experience\' regards, george yoshinaka
rabidraccoon Date: 20/11/2001
you can test your preloader by going to test movie, clicking view --> show streaming, then go to debug, and select the modem speed u want to test it at - this is with flash 5 - other versions may not have these options, or the commands might be under a different menu
rabidraccoon Date: 20/11/2001
oops sorry i didnt c ur comment there lol i didnt think any of u knew how to do that
alex Date: 03/12/2001
Hello, i got one question concerning this preloader: how can i hide the level1 movie (prevent it from playing), until it is fully loaded?! as soon as I load it it is displayed on top (in the background) of my preloader movie.... thanks in advance
Thomas Date: 13/12/2001
Thnx for the great preloader ;) I've got one problem.. I would like to display this other flash movie I am preloading in a different resolution.. (the same resolution as the preloading movie) how do I do that?
Ken Date: 15/12/2001
I used your preloader in the middle of a movie to get the main movie to pause while the loaded movie(which holds the music for the movie) loads completely as they both need to play at the same time. In frame 187, I assigned the following action: loadMovieNum ("Youth_main_music.swf", 1); In frame 253, I assigned the following action: actBytes = _level1.getBytesLoaded() || 0; totBytes = _level1.getBytesTotal() || 100; percent = Math.round(actBytes*100/totBytes); if (totBytes-actBytes>10) { gotoAndPlay (187); } The loops works and the level 1 movie does load; however, only the first frame or so plays because the main movie keeps repeating to frame 187 instead of continuing. What do I do?
Eric Date: 10/01/2002
This script does not work! It stays on frame 1 until the movie loads, then continues playing. The preloader never shows up.
Scott Date: 24/01/2002
I have the same prob as Alex...Basically what's happening is everything is working perfect now, and the bar and the whole bit, but the movie begins to play when it's not totally loaded yet. and when the bar gets to the end the movie starts to play fully which is what I want :) Here is my frame 3 code... others... this bar werks perfect... it's a little modified.. so that may be the problem... // get the bytes loaded so far or 0 if we didn't start loading yet actBytes = _level1.getBytesLoaded() || 0; // get the total bytes to load or 100 if we didn't start loading yet totBytes = _level1.getBytesTotal() || 100; // calculate a percentage value of the bytes loaded percent = Math.round(actBytes*100/totBytes); // if there are more bytes to load if (_level1.getBytesLoaded() < _level1.getBytesTotal()) { // if you don't want a bar, delete the following line bar._xscale = percent; // go back to the loop gotoAndPlay (2); } if (_level1.getBytesLoaded() >= _level1.getBytesTotal()) { gotoAndStop (1);}
Dave Date: 14/03/2002
I've been looking for this answer since four last night. If anyone can e-mail me the answer, I'd appeciate it. I have a loader extention, and I got it to function fine. But I can't get it to do exactly what I want. Here's what I'm doing, in simple talk. I'm making a website with Flash, and it's all going to be one page. If you hit the News button, the menu transforms into the News section. There's eleven different scenes, each scene with a different theme. The entire thing is 3 MB, which would take people forever to load. So I've made each section into it's own scene, and each scene has it's own loader. If you hit the News button, that scene will load. You get the idea. Here's my problem: Presuming I have 80 frames in scene one, how do I load only those 80 frames on that one scene, and not the entire movie? Remember that each scene will have it's own loader, and those loaders would probably act upon the same principle as the loader in scene one. This is the one stupid problem stopping my site from going up and I feel like an ass because I know the answer is going to be extremely simple. Please e-mail me with some help before I have another apoplexy. Thanks.
SG_01 Date: 03/04/2002
Ok I'm barely starting, how do I make the bar object?
shubie Date: 22/04/2002
It seems pretty much fine, but my problem is a step ahead. I have bg music in a separate swf file and this bg music is supposed to be started at frame 30. I already have an preloader fro my main movie. So how can I combine both? I just want to load my main movie as well as music movie before playing and when loaded the music should start playing at frame 30. Please help..... I might lose my business.
mike Date: 12/05/2002 the preloader will not show up?
sonia Date: 10/07/2002
heelo can anybody help me .... i made a site with the help of flash n all the links used as a different swf file .....which is given the script load movie action define by when i uploaded its coming properly.....means when clicking the link line by line its coming perfectly ..... like i hve movie with links abouts us,clients, products, contacts us,(all different swf file)...and give action load movie..level 1,2,3,4 so after into it goes to level 1 i.e is abouts us,then if clicking..clients level 2 like wise .....but then after checking all the links if i want to go back to abouts us...its not unloading last links i.e conatct us..... so i cant go back again if i want to check about us link.... y this happening
nikobe Date: 29/07/2002
even though i am not using your preloader script i am desperate to figure out my own. I have a simple "ifFramesloaded got to 3" in frame one and frame 2 "goback to 1". - On every scene of my seven scenes (so the movie doesn t load the entire 700kb at once- makes people leave) - what happens though is that it works but if i click the links (Scenes) in any order but the order they are in the flash file they simple ignore that and load in the "right" order. I click 5 - 1 will load, i click 4, 2 loads and so on - i ve checked the code a million times - i am lost (oh once all is loaded - it jumps finally to the right places) thanks 4 any help!!!!!!!!!!!
chris Date: 20/09/2002
this is *NOT* a preloader, its a "pause the main movie until the 2nd movie loads" script. A preloader would not reveal the 2nd movie until it was loaded fully. How you'd do this is by placing a clip OVER the 2nd movie, for example a white block called "whiteblock" and when it is fully loaded simply tell the code to unload whiteblock...
chris Date: 20/09/2002
the problem with placing a white block over the movie is that the movie will forever be over everything because its on level1... hmmm how would you make a *REAL* preloader when loading something to level1?
chris Date: 20/09/2002
figured it out. In your movie, make a new scene before your other scene and have it stop on the first frame of it. Then when this level is fully loaded, tell it to go to the next scene.
markb Date: 27/11/2002
Hi, I was just wondering about how the swf movie should be exported, ie top down or bottom up. I been having the prolem that you dont see the preloader at all, i just get a white screen until it has fully loaded, can anyone help, Thanks.
Tony Date: 02/02/2003
Does this code work with Flash 5? I have coded it exactly as shown with bizarre results. I have inserted debug text fields to identify the current frame. It freezes on frame 2, although it continues to process the code on 3. The code on frame 3 will not process unless there is a gotoAndPlay(2) on frame 4. After loading is complete, it ignores the variables on frame 3 and continues looping between frame 2 and 3. This defies all logic.
Jake Johnson Date: 09/06/2003
Hey I have a movie to load on an intro to a website I am making. I got the code but I don't know how to insert the code so it works. Please help an amateur at flash. Jake
Rafael Fernando Date: 23/01/2004
For god's sake, guys... is it so difficult to post an example .fla file? Why do you programmers just ignore the fact that beginners on actionscript that aren't familiar with this type of coding, and on most cases are familiar with visual aspects get lost on those brief raw code explanations on this site? At least be user-friendly and post some link with some usable tutorial that actually solve a problem. The code demonstrated here may be great, but without the right place for the right things, it don't even justifies it's presence here, for people who's looking for direct answers. Thanks anyway.
Add comment