4 Replies Latest reply on Oct 14, 2006 4:16 AM by Peter Lorent

    Preload External .swf WHILE Another is Playing

      My issue is this:

      I have a very large presentation. I need to split it up into "chapters" (similar to DVDs and whatnot). So, for each "chapter" or "section" I'll have an external swf, e.g. Chapter1.swf, Chapter2.swf... etc.
      I've created a Menu.exe which has buttons for each of the "chapters" or "sections". Each button, when clicked, will load the appropriate external swf into a placeholder movieclip which resides on the Menu.exe timeline.
      However, the problem arises when the external swfs are too large. For example, if Chapter2.swf has some video embedded in it, once the user clicks the "Chapter 2" button, they will have to wait several seconds for the Chapter2.swf to load before they can play the chapter. This can be unacceptable when the user has to wait 10 - 20 seconds on the larger files.
      And, I can't just load ALL the external swfs at the very beginning when the Menu.exe is launched, because then, instead of waiting a 10 seconds here and there, then the user has to wait MINUTES while the executable is launched.

      Ideally, I this is what I need to happen:
      The user launches the Menu.exe which will automatically load the first external swf (Chapter1.swf), which is a small file, so it will only take a second to load. Then, after Chapter 1 is loaded, I want to somehow load the other external swfs (or at least the next chapter) in the "background" so that the user can still view/play/pause Chapter 1 while the Chapter2.swf loads into another placeholder movie clip. This way, when the user is ready to advance to Chapter 2, and they click the Chapter 2 button, the Chapter2.swf will already be loaded and will come up immediately with no (or very minimal) delay.

      Is this even possible?
        • 1. Re: Preload External .swf WHILE Another is Playing
          S4Potential Level 1
          If your problem is only caused by the video then the best solution would be to link to external FLVs. They don't resides in the SWF, they load when needed, they stream, they're marvelous.

          Flash 8 provides a video converter. Sorenson Squeeze has a better one for $100

          If you cannot use FLVs, you would then need 2 empty movie clips as place holder, 3 if the user can go back to a previous chapter.

          Preload the first movie in clip 1, once loaded preload the second movie in clip 2, when clip 2 starts playing preload the third movie in clip one, etc...

          If youi provide back navigation then it is a bit more twisted but not that hard to do.

          Load swf 1 into clip 1, once loaded load swf 2 in clip two, once 2 is playing load swf 3 in clip 3, once swf 3 is playing load swf 4 in clip 1, if user goes back to clip 2 load swf 1 in clip 1, ect...

          But, FLVs are really the way to go. You could then load it all at once and play the videos with no delay in the loading of the SWF(s) and no delays in playing the videos.
          • 2. Re: Preload External .swf WHILE Another is Playing
            Peter Lorent Level 2
            Sure it's possible. And you can load chapter 3 when the user views chapter 2 and so on. And you do it with one instance of the MovieClipLoader Class. In Flash hit F1 and search for MovieClipLoader. Enough info there or dive into actionscript.org or kirupa.com or... there are loads of tutorials out there.
            • 3. Re: Preload External .swf WHILE Another is Playing
              badaboom55 Level 1

              1) Unfortunately, I am working in Flash MX (not 2004) so the MovieClipLoader Class is unavailable to me. So, that may be an insurmountable obstacle right off the bat.

              2) My problem isn't just video. Really, the problem is the file size of the SWFs, you put enough frames in a SWF (even if it's all vector) and you're going to have largish files. I mean, I'm not dealing with a couple hundred frames... I'm dealing with MINUTES worth, thousands of frames per SWF. So, I definitely need to have external SWFs and not just FLVs, because it's not just video, it's animations over video etc.

              3) I knew I would have to have several placeholder movie clips, I guess I'm just not sure about how to construct the actrionscripting to accomplish what I want...
              I guess what I mean is, I'm not sure of the logic I should use...
              Should I create a function on the Main timeline that will load the movies? Will the function be able to run while the user plays Chapter 1?
              I can't just put the script: placeholder2_mc.loadMovie("Chapter2.swf")
              on a frame in Chapter1.swf, because then the playback will hitch.
              • 4. Re: Preload External .swf WHILE Another is Playing
                Peter Lorent Level 2
                That certainly complicates things a bit more. You really need to consider an upgrade.
                The general principle: if the Chapter swf's have preloaders, instruct the preloader to set a var in the Main.swf - like chapter1=0 - to 1 (true); using the syntax _level0.chapter1=1;
                Now you need a setInterval in Main.swf that tracks what is happening to the chapter1 var. Call a function in the setInterval that checks whether chapter1==1 and if so, instruct the Main.swf to load the next chapter. To make the function reusable you can setup an array of the chapters and use the array index to track whether a chapter has loaded.