-
Preloading multiple external swf
HI, i am having al ot of trouble with this. I've tried a couple of example with little luck. i have a projects that consists of 7 swfs that play one after the other. i want them all to preload then play in the correct order. i'm not sure how to handle this. any help would be greatly appreciated!
-
use a empty MC acting as a controller. Using pairs of frames for loops. first pair preloads first swf then goes to 2nd pair, etc..
assuming you know how to script a preloader. If not there are hundreds of examples in this only forum.
gparis
-
i'm still totally confused
-
confused about which part?
-
Hi drew252,
This is for Flash MX
In your main Movie the following script.
///////////////////////////////////////////////////////////
stop();
numberOfMovies=7;
loadCount=0;
for(i=0;i<numberOfMovies;i++){
createEmptyMovieClip("mcHolder" + i,i+1);
}
function playMovies(){
_root.mcHolder0.gotoAndPlay(2);
}
loadStage=0;
loaderInterval=setInterval(loadChecker,100);
function loadChecker(){
if(loadCount<numberOfMovies){
if(loadStage==0){
loadMovie("movie" + loadCount+".swf",_root["mcHolder" + loadCount]);
loadStage=1;
}
else if(loadStage==1){
dataLoaded=_root["mcHolder" + loadCount].getBytesLoaded();
dataTotal=_root["mcHolder" + loadCount].getBytesTotal();
if(dataLoaded>=dataTotal && dataLoaded>0){
{loadCount++;loadStage=0;}
}
}
else if(loadCount>=numberOfMovies){
clearInterval(loaderInterval);
playMovies();
}
}
/////////////////////////////////////////////////////////////
Basicly this script first creates 7 Movie Clip
instances named "mcHolder0" to "mcHolder6".
Then it set an interval/timer that calls the
function loadChecker() this function loads all
7 external .swf files into the 7 Movie Clip
instances named "mcHolder0" to "mcHolder6".
When they are all loaded the function playMovies()
is called.
For this example the external .swf files must
be named "movie0.swf" to "movie6.swf". Each
of these external .swf files must have a blank
first frame with just a stop(); action. This is
to stop them streaming until ALL .swfs are loaded.
Also on their last frame they must start the next Movie
playing.
So as an example.
"movie0.swf"
Frame 1. blank with just a stop(); action.
Frame 2. Your stuff starts here.
Last Frame.
stop();
_root.mcHolder1.gotoAndPlay(2);
"movie1.swf"
Frame 1. blank with just a stop(); action.
Frame 2. Your stuff starts here.
Last Frame.
stop();
_root.mcHolder2.gotoAndPlay(2);
"movie2.swf"
Frame 1. blank with just a stop(); action.
Frame 2. Your stuff starts here.
Last Frame.
stop();
_root.mcHolder3.gotoAndPlay(2);
etc. etc.
Hope this helps .... lots to think about.
Milosav
-
Thanks you so much! I'm going to try it right away!
-
when i export it...i get 2 errors:
Scene=Scene 1, Layer=force, Frame=1: Line 18: Statement block must be terminated by '}'
function loadChecker(){
Scene=Scene 1, Layer=force, Frame=1: Line 39: Syntax error.
-
Hi drew252,
Sorry about that, I had one too many closing "}".
The following script publishes OK for me now.
stop();
numberOfMovies=7;
loadCount=0;
for(i=0;i<numberOfMovies;i++){
createEmptyMovieClip("mcHolder" + i,i+1);
}
function playMovies(){
_root.mcHolder0.gotoAndPlay(2);
}
loadStage=0;
loaderInterval=setInterval(loadChecker,100);
function loadChecker(){
if(loadCount<numberOfMovies){
if(loadStage==0){
loadMovie("movie" + loadCount+".swf",_root["mcHolder" + loadCount]);
loadStage=1;
}
else if(loadStage==1){
dataLoaded=_root["mcHolder" + loadCount].getBytesLoaded();
dataTotal=_root["mcHolder" + loadCount].getBytesTotal();
if(dataLoaded>=dataTotal && dataLoaded>0){
loadCount++;loadStage=0;}
}
}
else if(loadCount>=numberOfMovies){
clearInterval(loaderInterval);
playMovies();
}
}
Milosav
-
Hey !
gparis
How do I do it Flash 5 ?
If U can attch an FLA that would be fine,
'cos I am very poor at AS ...
-
First of all, thanks so much, it works perfect! Is there anyway to make it begin to play before it is finished downloading?
-
Hi drew2522,
Do you mean the script I posted works or
has gparis been able to help you out here?
Also when you say you want it to start playing
before it is downloaded, I am not sure what you
mean. Which of the seven preloaded Movies do you mean?
Sorry I am a little slow on the uptake this
afternoon.
Milosav
-
I searched and found this old post where i wrote some code and explanations on the method i described above (which will work in F5):
http://www.flashkit.com/board/showth...ing+and+gparis
gparis
Last edited by gparis; 03-23-2003 at 11:55 PM.
-
ahhh okay...heres what i ment. Is there anyway to make it begin playing even while it is preloading. like it it possible to have it play earlier while the the last couple of swfs are still loading?
-
Hi drew252,
Yes you can start playing them whenever you want.
The following is the same script but I have moved
the playMovie(); function call, and placed it within an
"if" conditional statement ...
if(loadCount==5){playMovie();}
As it is set up once Movie 4 has loaded then it
will start playing from Movie 1. Of course changing
4 to another number will make your Movies start
playing at a different time.
stop();
numberOfMovies=7;
loadCount=0;
for(i=0;i<numberOfMovies;i++){
createEmptyMovieClip("mcHolder" + i,i+1);
}
function playMovies(){
_root.mcHolder0.gotoAndPlay(2);
}
loadStage=0;
loaderInterval=setInterval(loadChecker,100);
function loadChecker(){
if(loadCount<numberOfMovies){
if(loadStage==0){
loadMovie("movie" + loadCount+".swf",_root["mcHolder" + loadCount]);
loadStage=1;
}
else if(loadStage==1){
dataLoaded=_root["mcHolder" + loadCount].getBytesLoaded();
dataTotal=_root["mcHolder" + loadCount].getBytesTotal();
if(dataLoaded>=dataTotal && dataLoaded>0){
if(loadCount==4){playMovie();}
loadCount++;loadStage=0;
}
}
}
else if(loadCount>=numberOfMovies){
clearInterval(loaderInterval);
}
}
Milosav
-
Thank you so much! You are spend too much time helping me out! I added the script you made, but it isnt loading, it just seems to hang.
-
Hi drew 252,
I tested this out and found another typo on
my part. The following works for me.
I was trying to call playMovie(); instead of
the correct playMovies();
stop();
numberOfMovies=7;
loadCount=0;
for(i=0;i<numberOfMovies;i++){
createEmptyMovieClip("mcHolder" + i,i+1);
}
function playMovies(){
_root.mcHolder0.gotoAndPlay(2);
}
loadStage=0;
loaderInterval=setInterval(loadChecker,100);
function loadChecker(){
if(loadCount<numberOfMovies){
if(loadStage==0){
loadMovie("movie" + loadCount+".swf",_root["mcHolder" + loadCount]);
loadStage=1;
}
else if(loadStage==1){
dataLoaded=_root["mcHolder" + loadCount].getBytesLoaded();
dataTotal=_root["mcHolder" + loadCount].getBytesTotal();
if(dataLoaded>=dataTotal && dataLoaded>0){
if(loadCount==4){playMovies();}
loadCount++;loadStage=0;
}
}
}
else if(loadCount>=numberOfMovies){
clearInterval(loaderInterval);
}
}
If you still have problems let me know and I
will send you my .fla files.
Milosav
-
It works perfectly. I just wanted to drop another line of thanks you really helped me out. i appreciate it a lot.
thanks,
Andrew
-
How would you write a preloader for your code below?
I have used this code for one of my movies successfully where I load 8 of 11 movies before play but would like to display a simple preloader while those 8 load. Any help would be appreciated!
Thanks,
Jenn
Originally posted by milosav
Hi drew 252,
I tested this out and found another typo on
my part. The following works for me.
I was trying to call playMovie(); instead of
the correct playMovies();
stop();
numberOfMovies=7;
loadCount=0;
for(i=0;i<numberOfMovies;i++){
createEmptyMovieClip("mcHolder" + i,i+1);
}
function playMovies(){
_root.mcHolder0.gotoAndPlay(2);
}
loadStage=0;
loaderInterval=setInterval(loadChecker,100);
function loadChecker(){
if(loadCount<numberOfMovies){
if(loadStage==0){
loadMovie("movie" + loadCount+".swf",_root["mcHolder" + loadCount]);
loadStage=1;
}
else if(loadStage==1){
dataLoaded=_root["mcHolder" + loadCount].getBytesLoaded();
dataTotal=_root["mcHolder" + loadCount].getBytesTotal();
if(dataLoaded>=dataTotal && dataLoaded>0){
if(loadCount==4){playMovies();}
loadCount++;loadStage=0;
}
}
}
else if(loadCount>=numberOfMovies){
clearInterval(loaderInterval);
}
}
If you still have problems let me know and I
will send you my .fla files.
Milosav
-
Senior Member
Here is a component movie preloader, which can preload up to 10 movies or jpgs in mcs, either random or consecutive names.
http://can_info_guide.tripod.com/com...omponents.html
- The right of the People to create Flash movies shall not be infringed. -
-
can we have buttons of next/previous option also with this. Pls tell me asap as i have a deadline to meet.
Regards
Jyotika
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|