I have a client who has this sytem built where he has a series of movies, but he wants every movie to have the same intro. So, he asked to have the intro movie check the database and to determine which movie to load in the intro movie. Anyway, everything works fine, except that when the movie is loaded, sometimes it doesn't show up right away and he is afraid some of his customers who view the movie, will be impatient and give up and think the movie is whacked. So, to prevent the problem, I wanted to know if there is anyway to preload external movies before they are loaded so we don't have that whitescreen error. I tried using a preloader on the external movie, except it didn't work because the movie hasn't even loaded in yet, so it can't preload. Any help is greatly appreciated.
You could probably start loading the movie off the screen during the into to let it load and/or I believe the getBytesLoaded() function can be applied to anything: loadedMovieClipName.getBytesLoaded(); and same with getBytesTotal();
How does your intro.swf load the external .swf files ie what code are you using to load the external files?
What are you loading the external files into?
If you are loading the external .swf files into a MovieClip that is in your intro.swf then I don't think you should be having any problems. Usually you would use some sort of visual progress report (ie a bar or text indicating progress of the file load) so that visitors to your site do not think that the site is whacked. The code you will need is usually described as preloader script, even though it is often used for what I would call "controled streaming".
ok, thanks for your help everyone, but I am still not quite there yet.
code:
loadMovieNum(getme, 0, "GET");
That is the code I use after the intro is over. Of course the variable getme is the name of the .swf of the movie that is retrieved from the database. It loads perfectly, but if the .swf isn't loaded into your cache before hand, it takes a several seconds to actually show the movie has loaded. I am kind of new at this whole load movie thing, as this is the first time I have worked with it, so that is why I may not sound too clear on these explanations. Thanks in advance for any help.
Not really an answer to your question, but a related side issue you should watch out for:
I recently ran into problems with loadMovie() comand in Opera Browsers, and I believe the problem also exists with loadMovieNum(). You need to use an absolute URL, otherwise it won't work.
Actually, I got some very strange results; when I opened just the swf in Opera, at full screen size, it would work, but any other size or embeded in HTML, it wouldn't load without the full URL. However, getBytesLoaded and getBytesTotal would both still return the full file size of the swf I was trying to load.
When you load a external file it replaces everything in the _level or MovieClip you load into ... this happens when you start the load. So in your case your intro.swf is cleared and then your external .swf starts loading. Of course it takes time for your external file to load so there is a period when you have no content. How long you have no content will depend on the size in kb of the external file. Of course if the file has been cached already due to a previous viewing then there will be very little delay loading it from the browser.
You need a preloader script to cover this period of delay and give your visitors something to let them know you site has not crashed ... a progress bar is often used.
Because you are loading into _level0 which is the _root of your Flash Movie your preloader script cannot be in the intro.swf as it would be replaced when you start loading the external file. So it will have to be in external file.
What version of Flash are you using? I can make an example of what you need and explain it to you but I only have Flash MX (version 6) ... it may not be compatible with what you have.
I am aware that it replaces the movie, and I did want it that way because like I had said it's only an intro and I perfer it to be replaced by the new movie. I am running on Flash MX, so any help with the preloading of this external .swf would be great. Again I appreciate your help shipstern. You have helped a lot.
There are a couple of ways you can do this depending on what your design concept was and if it can be realized without altering your setup (ie creating too much work).
The first thing is ... are your external.swf single frame? If they are not single frame then CAN they be streamed and still maintain your design concept? I say CAN as this is very different than you would like them too. You can test them using the Bandwidth profiler available under View when you TestMovie in the Flash IDE. Or you could upload them to the web and then view them in a browser but that's only how things are at your bandwidth and in your browser. If the content arrives in a bits and pieces manner then you may want to.
A: PRELOAD the files and when they are fullyloaded then play them.
B: Or break them up into smaller .swf files and do a controlled stream (this usually is a last resort as it can be a LOT of work).
C: Do a partial preload and begin playing when a percantage of the file had loaded.
If it looks like A B or C then I think you should consider that your intro provides an opportunity to be loading your external.swf while your intro is playing ... thats a big point to many intros ... functional art. This can be very easily accomplished it just requires starting to load your external.swf files on the first frame of the intro (rather than when the intro is completed) and load your external file int a higher _level .... then when they are loaded make the intro invisible with the actionscript ... _level0._visible=false; (which makes the intro invisible both visually and to events).
Let me what you think and I will code you an example or 2 it is way more simple than my explanation!!
Here is an example it is a basic preloader as I described.
I imagine you will need something more than just this. But it will let you see the basic concept working in a simple environment.
On Frame 1 of Intro.swf you will find the simple but effective preloader code. I have commented it bit.
It starts to load the external file into _level1.
Then checks if A the file is loaded and B is the intro completed. If both are true it makes the loaded external.swf on _level1 visible and the intro on _level0 invisible.
You may want to consider if your intro could be repeated (ie looped) and thereby become a preloader visual of sorts. Of course this may not fit your design at all but something to consider. Otherwise some sort of visual showing the progress of the external file load should most probably be used this can be very subtle ... just as long as your visitors know things are still in progress.
Thank you shipstern, you have helped greatly. Your code didn't work as I had wished, but it has gave me some ideas on a way to work around my problem. Again, I thank you and MD004 for your help. My client will be pleased.