laodBar tutorial

Hi,

I’ve got this from a kirupa-tutorial:

bytes_loaded = Math.round(_root.getBytesLoaded());
bytes_total = Math.round(_root.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
_root.loadBar._width = getPercent100;
_root.loadText = Math.round(getPercent
100)+"%";
if (bytes_loaded == bytes_total) {
_root.gotoAndStop(3);
}

What do I have to change so it doesn’t load the whole movie but only the scene it’s in, I don’t want to load everything at the same time… And if I load a external swf in my movie does the loadBar load this or do I have to put this script in the external swf file.

Hope you understand, thnx

LATO

Maby a stop at a specified frame?

scenes in flash suck. I never use them, I wish they didnt exist. They’re good n theory, in that they are a space saver and this is especially nice when doing straight animations in flash. However, in terms of coding, scenes themselves arent really specifically targeted. What flash does when it makes a swf is appends each scene at the end of the previous one just making one big long timeline. Therein adds the complications of scene navigation if youd ever tried going to a scene using gotoAndPlay with a nested button. It just doesnt work and you’ll have to use frame labels (or a _root based function) instead.

The way not to use scenes is by using movieclips or loading external swfs. External swfs seems like the way to go for you since you dont seem to want to load the whole movie in at once, something which will happen as soon as the movie is loaded into the browser. As soon as the swf starts loading, it wont stop until its done (or until its cut off somehow).

Pre-loader-wise, you can have a new preloader in each of the loaded movies which will initiate when that movie is called and loaded (which might be the easiest way depending on your setup) or you can re-use the one that you have in your main movie. If you reuse your main movies preloader then you’ll have to do some finagling to let it do that. This either by making it available through attachMovie or by hiding it in a movieclip on the maintimeline which, when its done loading, can just be sent to an empty frame to be hidden. If you do use the main movies preloader, you would also have to maintain the scope of the getBytesLoaded etc as a variable form so you can re-assign it to reference any loaded swf (or the main swf - _root to start) when it needs to be used.

bytes_loaded =itemToLoad.getBytesLoaded();
bytes_total = itemToLoad.getBytesTotal();
// round btw is redundant when used in a division below
getPercent = bytes_loaded/bytes_total;
_root.loadBar._width = getPercent100;
_root.loadText = Math.round(getPercent
100)+"%";

where itemToLoad is the variable you set to be whatever it is you want to load - initially _root for the main movie and then _root.container or _level2 or whatever it is you need to use it for