23 Replies Latest reply on Oct 23, 2007 2:47 AM by kglad

    Load and consecutively play external swf's

    Dani3838
      Hi,
      I have three external swf files - part1, part2 and part3. I know how to load one clip but I would like to know how to dynamically load them into an empty MC and then play them in full consecutively without any fancy transitions so that it plays like one big movie using Actionscript (no button triggers!).

      I have some very BASIC actionscript knowledge but am not sure which way is best. If someone could give me some "simple" step by step advise it would be grately apreciated.

      Danielle
        • 1. Re: Load and consecutively play external swf's
          kglad Adobe Community Professional & MVP
          1. start loading the first swf.
          2. when loading is complete, start its play and start loading the 2nd swf which should have an empty keyframe in its first frame and an attached stop().
          3. when the 2nd completes loading, start the 3rd which should also have an empty frame in frame 1 with a stop().
          4. when the first completes play start the 2nd.
          5. when the 2nd completes play start the 3rd.

          if you want to ensure seemless play with no lag between 1 and 2 and between 2 and 3, you'll need to ensure all 3 are loaded before you start playing 1.
          • 2. Re: Load and consecutively play external swf's
            Dani3838 Level 1
            Thanks for the quick reply. I understand the principles of your reply, however, I said I have BASIC knowledge!?

            I know that there are a couple of loadMovie commands but I have no idea where to start when writing full actionscript!!
            How do I start, how do I check it's loaded and where should each bit of actionscript go?

            I appreciate your probably busy working on your own fabulous Flash creations but if there is any actual code you could either show me or point me in the right direction I'd appreciate it. I've read the help files and forums but unless you know how to connect all the right different bits of code hints together then they don't help!

            Thanks again in advance. (Newbie actionscripter formally designer)
            • 3. Re: Load and consecutively play external swf's
              kglad Adobe Community Professional & MVP
              do you need to ensure that all are ready to play seemlessly with no delay between one ending and the other starting? can you edit the 3 external swf files so adding a blank frame to frame 1 with a stop() is no problem (and adding code to the last frame is no problem)?
              • 4. Re: Load and consecutively play external swf's
                Dani3838 Level 1
                Ideally they need to play seamlessly it's one story with continuous audio that was too big for one file and so are chopped into three smaller ones (originally for a DVD movie).
                Yes no problem adding frames and code to beginning and end as I have the FLA's
                • 6. Re: Load and consecutively play external swf's
                  Dani3838 Level 1
                  Ok I followed your instructions and when I play the main swf (I call - load_swfs) file it plays part1.swf fine but then it gets to the first frame of part2.swf (which is blank) and just stops and doesn't go any farther! Did I put something in the wrong place? I've written what I did and where below.

                  // In my main file (load_swfs) it's just a single blank frame with this code in it :-

                  tl=this;
                  swfA=["part1.swf","part2.swf","part3.swf"];
                  dep=0;
                  numLoaded = 0;
                  totalLoad=3;
                  lo=new Object();
                  lo.onLoadInit=function(target){
                  numLoaded++;
                  checkIfAllLoaded();
                  }
                  function checkIfAllLoaded(){
                  if(numLoaded==totalLoad){
                  holder1.play();
                  } else {
                  mc=this.createEmptyMovieClip("holder"+(numLoaded+1),dep++);
                  mcl.loadClip(swfA[numLoaded],mc);
                  }
                  }
                  mcl=new MovieClipLoader();
                  mcl.addListener(lo);
                  mc=this.createEmptyMovieClip("holder"+(numLoaded+1),dep++);
                  mcl.loadClip(swfA[numLoaded],mc);

                  // In part1.swf in the last frame is :-

                  tl.holder2.play();
                  this.removeMovieClip();

                  // In part2.swf frame 1 is blank with a stop(); and in the last frame is:-

                  tl.holder3.play();
                  this.removeMovieClip();

                  // In part3.swf frame 1 is blank with a stop();

                  Let me know where I went wrong!

                  Thanks
                  • 7. Re: Load and consecutively play external swf's
                    kglad Adobe Community Professional & MVP
                    do you have code in the last frame of part1.swf? does the last frame play?
                    • 8. Re: Load and consecutively play external swf's
                      Dani3838 Level 1
                      Yes in the last frame of part1.swf the actionscript is :-

                      tl.holder2.play();
                      this.removeMovieClip();

                      I even tried this:

                      tl.holder2.play(2);
                      this.removeMovieClip();

                      thinking it might play from frame 2 but no luck!
                      And yes it does appear to be clipping the last few frames when it stops playing!!
                      • 9. Re: Load and consecutively play external swf's
                        kglad Adobe Community Professional & MVP
                        in that last frame of part1.swf, use the following and paste the output here:

                        • 10. Re: Load and consecutively play external swf's
                          Dani3838 Level 1
                          Output window reports:-

                          last frame:undefined:
                          • 11. Re: Load and consecutively play external swf's
                            kglad Adobe Community Professional & MVP
                            post a link to your fla.
                            • 12. Re: Load and consecutively play external swf's
                              Dani3838 Level 1
                              Hi I followed your previous instructions and replaced.

                              .tl
                              with
                              _level0.tl

                              in the last frames of part1 and part2.

                              Now the three swf's play one after another but it's still cutting off the last few frames of the previous swf and showing the blank first frame for a few seconds! Any more thoughts?
                              • 13. Re: Load and consecutively play external swf's
                                kglad Adobe Community Professional & MVP
                                what makes you think that "frames" are cutting off? is there something in the next-to-last frame that you're not seeing? (and as for sounds, as i mentioned before, streaming sounds are not sync'd with frames - use event sounds.)
                                • 14. Re: Load and consecutively play external swf's
                                  Dani3838 Level 1
                                  Sorry, It seems one of your postings didn't appear (maybe due to the forum change?)! So I didn't know about your suggestion to use an event sound.

                                  However my audio is one very long file (backing audio, sound effects and voices originally designed for DVD) and I thought it wasn't a good idea to use this type of audio as an event sound! If you think it would control it better I'll give it a go unless you have an other idea.

                                  As for the frames missing at the end of each swf, I can tell because both the frames and audio are missing. They stop in the middle of the sentence and don't appear to be out of sync it just stops approx 29frames from the end of the file and then I get the black 1st frame of the next swf!
                                  • 15. Re: Load and consecutively play external swf's
                                    kglad Adobe Community Professional & MVP
                                    you can't conclude any frames are being cut unless there's some object(s) visible in one or more of those 29 frames that you failed to see. otherwise, you're seeing (hearing) the results of your streaming sound being cut-off when the last frame plays.

                                    you have much more control of your sounds if you use the flash sound object to create and control your sounds. in this situation, you could create your sound object, attach and start your sound and then use the onSoundComplete method in your last frame to trigger that code that's current there.
                                    • 16. Re: Load and consecutively play external swf's
                                      Dani3838 Level 1
                                      Ok, creating a sound object as you suggested sounds great and I should try that.
                                      However I don't know how, (Sorry!) I had a quick look online at tutorials and stuff but all seem to be triggered by a button and I have no buttons. Can it be done with an empty holder of some kind? Can you give give me some hints. Like I said new to all of this.

                                      Thanks again for you time and wisdom.
                                      D
                                      • 17. Re: Load and consecutively play external swf's
                                        kglad Adobe Community Professional & MVP
                                        you don't need a button. just remove the sound from the timeline. then right click on the sound in your library, tick export for actionscript and in the linkage id box type: soundID.

                                        then, in the actions panel, attached to the frame where you want your sound to start paste:

                                        • 18. Re: Load and consecutively play external swf's
                                          Dani3838 Level 1
                                          Created the sound object using your code and it does plays and does wait until the last frame of animation.
                                          Unfortunately it's now totally way out of sync!
                                          I don't know what to do now. I guess I'll have to go back to stream sound because thats the way it was animated to the wave form but that still wont resolve my original issue with the sound. I don't know actionscript much but from your code for the sound object I see it has a timeline complete, could something like that work to make it all finish together?

                                          As always, your ideas are most welcome. D
                                          • 19. Re: Load and consecutively play external swf's
                                            kglad Adobe Community Professional & MVP
                                            when you use an event sound, your timeline and sound are out of sync? if so, then it's an illusion (that only you see because you're testing locally) that they are in-sync when you stream your sound. if this is an going to be an online application, you're going to see different results when you upload and test online or when you simulate downloading in the test environment.

                                            i recommend you do just that: simulate downloading with your streaming sound or test using a server to see what everyone else is going to see (and hear).
                                            • 20. Re: Load and consecutively play external swf's
                                              Dani3838 Level 1
                                              I tested online as you suggested and it's definitely out of sync. I then exported them with streaming sound as quicktime files and they play in sync!
                                              This particular project was odd in as much as it was originally designed for a DVD and then the client wanted it as a download, so for this one I think it will be better left as quicktime files. But I have other (smaller) animation projects coming up both for online and DVD and I was hoping this would set me up with how to work on them as I had never used sound in this way and I was worried about sync, time frames differences for web and DVD and having to link multiple files.

                                              If I was to start a new project from scratch, how would you suggest would be the best way to make it all go smoother?
                                              • 21. Re: Load and consecutively play external swf's
                                                kglad Adobe Community Professional & MVP
                                                you might look at flash video (flv) files.
                                                • 22. Re: Load and consecutively play external swf's
                                                  Dani3838 Level 1
                                                  Yes I think it's the best way.

                                                  Thanks again for your help and advice, much appreciated.
                                                  D
                                                  • 23. Re: Load and consecutively play external swf's
                                                    kglad Adobe Community Professional & MVP
                                                    you're welcome.