6 Replies Latest reply on Mar 22, 2007 2:24 PM by JLgraphicFX

    Multiple Preloaders for Multiple Movie Clips

    JLgraphicFX
      Designed in Flash 8, the site's timeline is all in Scene 1 and is comprised of an introduction, which contains a short video, and 6 movie clip categories that the user selects to view. Since I want the intro to play as soon as possible, I'd like to limit the first preloader to just the video in the intro and not _root.getBytesTotal. Then, as the viewer watches this short video, the rest of Scene 1 movie clips will keep on loading. After the intro, the viewer will choose which of the 6 categories to view. These categories are identified with buttons which play the particular movie clip. Since I don't know the order of the categories they will select, I thought there should be a separate preloader for each category. Hopefully, after they view a category, the rest of the categories will have loaded and the loading time will be nil. The design for the preloader is comprised of a status bar and a percent loaded. Is there a way to limit the _root.GetBytesTotal to specific frames? I know I could break these categories up into separate SWF files but then I loose the advantage of one loading while another is being viewed.
        • 1. Re: Multiple Preloaders for Multiple Movie Clips
          SymTsb Level 2
          look into the MovieClipLoader class
          • 2. Re: Multiple Preloaders for Multiple Movie Clips
            JLgraphicFX Level 1
            I don't know what you mean. I am a designer and not very ActionScript savvy.
            • 3. Re: Multiple Preloaders for Multiple Movie Clips
              SymTsb Level 2
              MovieClipLoader is a built in class of functions that will allows you to easily load Media (swfs/jpgs) from external sources.

              This will create a MCL object
              var mcl:MovieClipLoader = new MovieClipLoader

              We want the MCL object to receive events for any movie that is loaded into the main timeline
              mcl.addListener(this);

              Ok. now we have a movie clip loader that is able to recieve events. Since we want to show the progressive download and want to do something with that content after it loads, we need to declare two event handlers onLoadProgress and onLoadInit. onLoadProgress is pretty straight forward. onLoadInit executes it's action as soon all of the AS on frame 1 of its time has finished loading. In this case, we want two different things to happen. 1st, load the first clip and show it.... 2nd, load all remaining clips into the buffer. But first, lets declare those next...

              function onLoadProgress( target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
              // standard preloader code goes here
              }

              function onLoadInit( target:MovieClip ):Void {
              // display the clip - this will be as easy as just calling our loadClip function for the mcl...more on that in a minute
              // If you want something special to happen, i.e. movie fades in or a mask is applied to it, you'd do that here.
              }

              Now all we need to do is call the loadClip member function for the MovieClipLoader. Just replace the two parameters with the location of the swf and then the name of the instance you want it to load into

              mcl.loadClip( "myswf.swf", targetMovieClip );

              The other movie clips are now a breeze as well. For each button, just add an on(release) or onRelease = function (depending on your situation) to just call that mcl.loadClip() line from up above. Just change the movie you want loaded.

              Let me know if you need more help...
              • 4. Re: Multiple Preloaders for Multiple Movie Clips
                JLgraphicFX Level 1
                Thanks so much, Sym Tsb. I tried your code and, while it worked for the intro, I could not get the progress bar to go away once the loading was completed. So, I found this other code that worked, which was similar to yours:

                var myMCL:MovieClipLoader = new MovieClipLoader();
                var myListener:Object = new Object();
                myMCL.addListener(myListener);
                myListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
                var loaded:Number = Math.round((bytesLoaded/bytesTotal) * 100);
                progressBar.gotoAndStop(loaded);
                }
                myListener.onLoadInit = function (target_mc:MovieClip) {
                progressBar._visible = false;
                loading._visible = false;
                }
                myListener.onLoadStart = function (target_mc:MovieClip) {
                progressBar._visible = true;
                loading._visible = true;
                }
                myMCL.loadClip("portfolio-1-intro.swf", "SWFcontainer");

                However, since the main SWF is now the preloader SWF, the buttons in the loaded SWF, portfolio-1-intro.swf, no longer work when calling myMCL.loadClip and inserting another SWF into the container. I believe it is because myMCL.loadClip is in _root because it is in the preloader SWF, and the loaded SWF where the buttons are are in another level. Yes? Also, the other SWFs were not loading in the background.

                PLEASE HELP!!!!
                • 5. Re: Multiple Preloaders for Multiple Movie Clips
                  SymTsb Level 2
                  It's going to require two seperate MovieClipLoader classes to achieve this. Let me scrounge around my computer and I'll post an FLA example. I know I have one somewhere.
                  • 6. Re: Multiple Preloaders for Multiple Movie Clips
                    JLgraphicFX Level 1
                    Thanks, I anxiously await your FLA!