2 Replies Latest reply on May 19, 2006 6:02 PM by Rothrock

    Preloading SWFs

    Rabaab_m
      I have a project which, due to the large number of PNG files, I have broken up into several smaller SWFs. I have so far successfully managed to get them all to play in sequence using the Load External Movieclip behaviour on the last frame of
      each, so that it starts playing the first SWF and then successively loads the next and then the next.

      Now the problem: this project is NOT for playback on the Internet, but rather will be used as a presentation. So I assumed that using the Load External Movieclip would give smooth playback as I don't have to take bandwidth into account.

      However, each time a new Movieclip has to load, there is a lag... if it is playing off a CD-ROM, the CD starts spinning again, if it is on the local hard drive the lag is less but still noticeable.

      So how can I avoid this? Do I need to make a preloader for this? Or can I put some ActionScript in the first movie which will preload all the subsequent SWFs without needing to make a preloader/progress bar?

      And please in any answers, be as obtuse as possible... I'm very, very new with AS!

      Cheers
      Rabaab
        • 1. Re: Preloading SWFs
          Level 7
          "Rabaab_m" <webforumsuser@macromedia.com> wrote in message news:e4kf2b$hh$1@forums.macromedia.com...
          > However, each time a new Movieclip has to load, there is a lag... if it is
          > playing off a CD-ROM, the CD starts spinning again, if it is on the local hard
          > drive the lag is less but still noticeable.
          >
          > So how can I avoid this? Do I need to make a preloader for this? Or can I
          > put some ActionScript in the first movie which will preload all the subsequent
          > SWFs without needing to make a preloader/progress bar?
          >
          > And please in any answers, be as obtuse as possible... I'm very, very new with
          > AS!
          >
          > Cheers
          > Rabaab

          Under those conditions you can load everything right in the beginning and just wait for everything to load up. That puts all the
          loading lag up front in one lump without spreading the lag through the whole presentation. Since it's loading locally you don't
          have to worry about the wait.

          Since you would be loading everything, you don't want everything to show, just parts of it. To do that you can either set
          visibility to off for movieclips that you load into or position out of view or the option that I like.. Make all the external swfs
          have a blank frame 1 and a stop command. When you want to hide them, move them to frame 1. When you want to show them, move them
          to frame 2 and play. Each swf can have it's own preloader that does nothing more than set a flag variable to notify the main swf
          that it is loaded.
          Details if you need it.

          tralfaz


          • 2. Re: Preloading SWFs
            Rothrock Level 5
            There is no way to do a preloader – in the regular sense – when playing from a local system. The Flash player just loads the whole thing in "one chunk" so getBytesLoaded will go from nothing to total in one step and the MovieClipLoader class's onLoadProgress will not be called.

            tralfaz's solution is a likely candidate. If the files are really huge it could still cause some memory/playback problems. Actually the upfront load-up can cause a problem. I've had rare occurrences where – on mostly slower, older machines – the projector would "stall" part way through the first frame. Adding 5 to 10 blank frames at the beginning seemed to help. Just keep that in mind.

            Also, depending upon the exact needs, you could do something like have some code that checks an XML file or some such every minutes or what have you. That would keep the CD or HD spinning.

            PS: You might want to look up "obtuse" in a dictionary! (I guess one meaning could mean what you meant, but I think that really only applies to geometry.)