5 Replies Latest reply on Oct 14, 2009 6:48 PM by peterOxley

    movieClipLoader Preloader

    peterOxley

      Hello

       

      I am using Flash MX pro 2004. This should be my last problem before finishing my new website!

       

      I currently have designed my first flash website using loadMovie to load each scene with a preloader where necessary. This has failed to work properly so I am endeavouring to switch website FLA to using movieClipLoader Class to load the Preloader where needed. I have placed the following actionscript 2 on the first frame of the first Intro scene to create the Preloader listener and MCL.

       

      Can someone please have a look to see if this right.

       

      var myMCL:MovieClipLoader = new MovieClipLoader();
      var myListener:Object = new Object();
      myMCL.addListener(myListener);
      myListener.onLoadProgress = function (target_mc, loadedBytes, totalBytes) {
      _level25._visible = true;
      var preloadPercent:Number = Math.round(loadedBytes / totalBytes * 100);
      _level25.preloader.gotoAndStop(preloadPercent);
      }
      myListener.onLoadComplete = function (target_mc) {
      _level25._visible = false;
      }
      Note where it says _level25.preloader does this need to point to the movieclip instance name within the preloader scene (as it does now) or does it need the name of the preloader scene itself ratio_Preloader.swf?
      Note level 25 is above all other levels.
      Then as an example in one of the menus the following is placed on the movieclip button,
      on (press) {
      myMCL.loadClip("ratio_XmasImage_1.swf", 20);
      myMCL.loadClip("ratio_Preloader.swf", 25);
      }
      Currently this does not work at all, no sign of preloader or final image. I want the Preloader to listen in this example to the XmasImage downloading.
      Clearly getting this majorly wrong. Please help !!
      Best
      Pete

        • 1. Re: movieClipLoader Preloader
          kglad Adobe Community Professional & MVP

          are you publishing for flash player 7 or greater?

          • 2. Re: movieClipLoader Preloader
            peterOxley Level 1

            Hello Again

             

            Yes it will be published for Flash Player 7.

             

            Best

            Pete

            • 3. Re: movieClipLoader Preloader
              peterOxley Level 1

              Hello

               

              I keep rereading my manual FlashMx 2004 Beyond the basics. Can you just explain the general mechanics of where script is placed to make a preloader work?

              I think the general concept is where I am failing.

              I read that you generate the MCL and listener on frame 1 of scene 1. Does one load the preloader here or later when loading the actual scene that needs the preloader? Does the preloader load once at the start or does it download every time for each scene?

               

              Any pointers as well as on my previous scripting massively appreciated.

               

              best Pete

              • 4. Re: movieClipLoader Preloader
                kglad Adobe Community Professional & MVP

                then you can use the mcl class.  you just need to clean up your logic and code.  the following will, for the most part, work.  but if you want your preloader to complete loading before you start loading that other swf, you'll need to do a bit more:

                 

                var myMCL:MovieClipLoader = new MovieClipLoader();
                var myListener:Object = new Object();
                myMCL.addListener(myListener);
                myListener.onLoadProgress = function(target_mc, loadedBytes, totalBytes) {
                    var preloadPercent:Number = Math.round(loadedBytes/totalBytes*100);
                    _level25.preloader.gotoAndStop(preloadPercent);  // assuming you have a movieclip with instance name preloader in ratio_Preloader.swf
                };
                myListener.onLoadComplete = function(target_mc) {
                    unloadMovieNum(25);
                };

                 

                yourbutton.onRelease = function() {
                    myMCL.loadClip("ratio_XmasImage_1.swf",20);
                    loadMovieNum("ratio_Preloader.swf",25);
                };

                • 5. Re: movieClipLoader Preloader
                  peterOxley Level 1

                  Hello

                   

                  Many thanks for the code advice so far. I need to clarify where to put all the code as still unsure the exact mechanism of how it all works.

                   

                  SO_

                   

                  I presume I put on the first frame of the first intro scene_

                   

                  var myMCL:MovieClipLoader = new MovieClipLoader();
                  var myListener:Object = new Object();
                  myMCL.addListener(myListener);
                  myListener.onLoadProgress = function(target_mc, loadedBytes, totalBytes) {
                      var preloadPercent:Number = Math.round(loadedBytes/totalBytes*100);
                      _level25.preloader.gotoAndStop(preloadPercent);

                  // assuming you have a movieclip with instance name preloader in ratio_Preloader.swf - THIS IS CORRECT
                  };
                  myListener.onLoadComplete = function(target_mc) {
                      unloadMovieNum(25);
                  };

                   

                  THEN_

                   

                  I take it I put the next part of the code on the first frame of the menu scene deeper in to the website where I want the menu button to trigger the swf to load preceded by the Preloader that monitors its download progress_

                   

                  yourbutton.onRelease = function() {
                      myMCL.loadClip("ratio_XmasImage_1.swf",20);
                      loadMovieNum("ratio_Preloader.swf",25);
                  };

                   

                  I need to get this right as it only tests correctly when loaded up to a server according to my book due to a glitch in Flash MX 2004. Therefore it will take a wee while to test.

                   

                  Look forward to your reply.

                  Best

                  Pete