PDA

View Full Version : Preloader "Philosophy"?


nickej
08-12-2003, 12:54 PM
I've got a question about preloaders, but it's more of a "Why does it do what it does?" question than a "how to?" question.
If I have a document that is made up of two scenes, a main scene and a preloader, what are the conditions that the Flash Player or browser looks for to play the preloader first? In other words, how does it tell which is the preloader and which is the main scene. Does it just play whatever it can find and the preloader, being smaller, goes first?
I ask because I've seen many demo scenes with no discernable code in the main scene with anything resembling a "wait until you get the signal from the preloader" code. I would think that that would have an equal chance of playing a few frames as the preloader would....

Warrior
08-12-2003, 01:03 PM
It's nothing to do with the browser, it's the Flash movie it's self. You're telling Flash which scene should go first and Flash say's, "ok". In the first scene you're puting a code that also tells Flash to show how much or wait for the whole movie to load before showing it. It's just another language, why do you need to walk before you can run ;)

nickej
08-12-2003, 01:30 PM
Thanks for the reply!
but....Where do you say that?
As an example, from a book I'm using "Flash MX Complete Course"(Seybold), the preloader has this bit of code in the first frame:
var nowLoaded = _root._framesloaded;
var totalLoaded = _root._totalframes;
if (nowLoaded == totalLoaded) {
gotoAndPlay("Introduction", 1);
}
along with a loop-making gotoAndPlay on the second frame.
The main scene has no code at all and is just a straight ahead animation.

Does the existence of the gotoAndPlay("Introduction",1); instruction mean that Flash may not play the other scene until told to by the preloader? Is this what is meant by Flash always reading the Actionscript before displaying the frame?

Warrior
08-12-2003, 01:45 PM
Does the existence of the gotoAndPlay("Introduction",1); instruction mean that Flash may not play the other scene until told to by the preloader? Is this what is meant by Flash always reading the Actionscript before displaying the frame? No. Lets go through the code line by line.

var nowLoaded = _root._framesloaded;
This line tells Flash how many frames have loaded for the movie.

var totalLoaded = _root._totalframes;
Thsi line tells Flash to get the Total frames used in the movie

if (nowLoaded == totalLoaded) {
This line is a Boolean which is testing if the condition is true or not. If the frames being loaded is equal the total frames in the movie.

gotoAndPlay("Introduction", 1);
Go to and Play "Framelable" in scene one. The gotoAndPlay(1); on frame 2 is calling the preloader code to loop it and go through the loading process again untill the movie has loaded.

fgf
08-12-2003, 06:12 PM
stop using scenes, they don't exist.

The preloader 'scene' is just the first few frames of the movie.

if scene 1 is 4 frames scene 2,frame 1 is just frame 5.

they only exist in the authoring tool to confuse people. They are ignored in the swf.

What a preloader actually does is hang about on a couple of frames until the whole swf is loaded then just plays normally.

fgf

P.S. I'm just gonna put this in my sig and leave blank posts everywhere

nickej
08-12-2003, 06:24 PM
Actually, I get that stuff....:-)

My question is more "What's stopping the other one from playing first?" . Both scenes start hitting the playing computer at almost the same time, right? It's packet data, after all. One of them can load entirely, and in a hurry (the preloader) the other (the main movie) can maybe only play a frame or two before waiting for more data. Where in the SWF does it say "Ignore the main movie until it's loaded". I understand that in the preloader scene it says that (Ignore that other one over there), but what if, for the sake of argument, the player just happpens to grab onto the main scene first, play a few frames, wait, finally play the whole thing, and THEN get around to looking at the preloader and following its instructions.....
To put it another way, given two scenes that make up a movie, where is the data (or metadata) that tells the player which to load first? Or is an SWF like an old LP... arranged in a sequential order when it's compiled....
If that's the case, where's the information that determines the sequence if it isn't explicitly coded by the author? In other words, is playing an SWF like starting an old LP from the beginning and then moving the needle according to instructions, in which case: what bit of code defines the beginning? Or is it more like dropping the needle at random on an old LP, and then following the instructions from there on, in which case: Where is the instruction that spits it back to the beginning if it hasn't been coded in?
I'm sorry if this is particularly idiotic of me....you've been most considerate already....

nickej
08-12-2003, 06:30 PM
Scenes don't EXIST?!? The *****'s! How dare they! Son of a ******! I had no problem doing preloaders until the idea of "scenes" entered into it! I actually thought that scenes were a form of higher encapsulation, like clips, rather than a sort of elaborate frame label....
I believe I get it, now.......
Thanks!