A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 21

Thread: Preloading multiple external swf

  1. #1
    Junior Member
    Join Date
    Jan 2002
    Posts
    10

    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!

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    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

  3. #3
    Junior Member
    Join Date
    Jan 2002
    Posts
    10
    i'm still totally confused

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    confused about which part?

  5. #5
    Senior Member
    Join Date
    Nov 2002
    Posts
    195
    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

  6. #6
    Junior Member
    Join Date
    Nov 2000
    Posts
    2
    Thanks you so much! I'm going to try it right away!

  7. #7
    Junior Member
    Join Date
    Jan 2002
    Posts
    10
    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.

  8. #8
    Senior Member
    Join Date
    Nov 2002
    Posts
    195
    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

  9. #9
    :mad: 4 U
    Join Date
    Aug 2001
    Location
    Bangalore,INDIA
    Posts
    90
    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 ...

  10. #10
    Junior Member
    Join Date
    Jan 2002
    Posts
    10
    First of all, thanks so much, it works perfect! Is there anyway to make it begin to play before it is finished downloading?

  11. #11
    Senior Member
    Join Date
    Nov 2002
    Posts
    195
    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

  12. #12
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    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.

  13. #13
    Junior Member
    Join Date
    Jan 2002
    Posts
    10
    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?

  14. #14
    Senior Member
    Join Date
    Nov 2002
    Posts
    195
    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

  15. #15
    Junior Member
    Join Date
    Jan 2002
    Posts
    10
    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.

  16. #16
    Senior Member
    Join Date
    Nov 2002
    Posts
    195
    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

  17. #17
    Junior Member
    Join Date
    Jan 2002
    Posts
    10
    It works perfectly. I just wanted to drop another line of thanks you really helped me out. i appreciate it a lot.

    thanks,
    Andrew

  18. #18
    Junior Member
    Join Date
    May 2001
    Posts
    28
    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

  19. #19
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    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. -

  20. #20
    Junior Member
    Join Date
    Sep 2000
    Posts
    11
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center