20 Replies Latest reply on May 22, 2009 3:28 AM by gotoAndExplore

    external preloader script problem

    gotoAndExplore

      hi, i'm try to create an external preloader, i've made three layers (the script, one for a funky design of my logo and keep things simple i've also embedded the preloader text in this layer and finally the preloader bar beneath. i've created two frames for each layer, the script has two keyframes, the other layers only have a keyframe first then a standard frame. i can't get it work though, please help. here's the script i'm using on the second keyframe.

       

      var loader:MovieClipLoader = new MovieClipLoader();

      this.createEmptyMovieClip("Empty_movieclip",1);

      loader.loadClip("Creative-Outrage.swf",Empty_movieclip);

       

      var preload:Object = new Object();

      loader.addListener(preload);

       

      preload.onLoadProgress = function (target, loadedBytes, totalBytes){

      if (_root.getBytesTotal() != _root.getBytesLoaded()){

      gotoAndPlay(1);

      }

      else (loadMovie("Creative-Outrage.swf",Empty_movieclip));

      removeMovieClip("Preloader_movieclip");

      }

       

      Bar_movieclip._xscale=(_root.getBytesLoaded()/_root.getBytesTotal())*100;

       

      Preloader_movieclip.Loader_text.text=Math.round((_root.getBytesLoaded()/_root.getBytesTota l())*100)+"% Complete";

        • 1. Re: external preloader script problem
          kglad Adobe Community Professional & MVP

          move your loadClip() method so it executes after the rest of the code you displayed.  and use the loadedBytes and totalBytes parameters in your onLoadProgress method, not _root.getBytesLoaded() and _root.getBytesTotal().

          • 2. Re: external preloader script problem
            gotoAndExplore Level 1

            like this?:

             

            var loader:MovieClipLoader = new MovieClipLoader();

            this.createEmptyMovieClip("Empty_movieclip",1);

            loader.loadClip("Creative-Outrage.swf",Empty_movieclip);


            var preload:Object = new Object();

            loader.addListener(preload);

             

             

            Preloader_movieclip.Bar_movieclip._xscale=(loadedBytes/totalBytes)*100;


            Preloader_movieclip.Loader_text=Math.round((loadedBytes/totalBytes)*100)+"% Complete";


            preload.onLoadProgress = function (target,loadedBytes,totalBytes){

            if (loadedBytes = totalBytes){

            (loadMovie("Creative-Outrage.swf",Empty_movieclip));

            removeMovieClip("Preloader_movieclip");

            }

             

            else {

            gotoAndPlay(1);

            }

            }

             

            it's still not displaying any gradual progress, it just displays the full progress bar immediately even when i simulate a download and it's not loading the external file either.

            • 3. Re: external preloader script problem
              kglad Adobe Community Professional & MVP
              try:

               

              var loader:MovieClipLoader = new MovieClipLoader();

              this.createEmptyMovieClip("Empty_movieclip",1);


              // move the next line to the end of your code

              loader.loadClip("Creative-Outrage.swf",Empty_movieclip);


              var preload:Object = new Object();

              loader.addListener(preload);

               

               

              // the next two lines should be in preload.onLoadProgress

               

              //Preloader_movieclip.Bar_movieclip._xscale=(loadedBytes/totalBytes)*100;


              //Preloader_movieclip.Loader_text=Math.round((loadedBytes/totalBytes)*100)+"% Complete";


              preload.onLoadProgress = function (target,loadedBytes,totalBytes){

              if (loadedBytes = totalBytes){

              // (loadMovie("Creative-Outrage.swf",Empty_movieclip));  <-- comment out or remove this line

              removeMovieClip("Preloader_movieclip");

              }

               

              else {

              gotoAndPlay(1);

              }

              }

               

              it's still not displaying any gradual progress, it just displays the full progress bar immediately even when i simulate a download and it's not loading the external file either.

              1 person found this helpful
              • 4. Re: external preloader script problem
                gotoAndExplore Level 1

                to help you work out what i'm doing wrong i've uploaded the preloader and the external swf file to my website - www.creative-outrage.com, for some reason it's not displaying at all in firefox but loads the preloader ok in safari with errors in the activity window.

                • 5. Re: external preloader script problem
                  gotoAndExplore Level 1

                  it's helped, now it's trying to display the download progress when do a simulation, but it gets stuck at the beginning. although i've uploaded this new swf file to the website and it immediately loads a full progress bar but doesn't load the external file and has no errors in safari's activity window this time. here's what i did:

                   

                  var loader:MovieClipLoader = new MovieClipLoader();

                  this.createEmptyMovieClip("Empty_movieclip",1);


                  var preload:Object = new Object();

                  loader.addListener(preload);


                  preload.onLoadProgress = function (target,loadedBytes,totalBytes){

                  Preloader_movieclip.Bar_movieclip._xscale=(loadedBytes/totalBytes)*100;

                  Preloader_movieclip.Loader_text=Math.round((loadedBytes/totalBytes)*100)+"% Complete";

                  if (loadedBytes = totalBytes){

                  (loadMovie("Creative-Outrage.swf",Empty_movieclip));

                  }

                  else {

                  gotoAndPlay(1);

                  }

                  }


                  loader.loadClip("Creative-Outrage.swf",Empty_movieclip);

                  • 6. Re: external preloader script problem
                    kglad Adobe Community Professional & MVP
                    again

                     

                     

                    var loader:MovieClipLoader = new MovieClipLoader();

                    this.createEmptyMovieClip("Empty_movieclip",1);


                    var preload:Object = new Object();

                    loader.addListener(preload);


                    preload.onLoadProgress = function (target,loadedBytes,totalBytes){

                    Preloader_movieclip.Bar_movieclip._xscale=(loadedBytes/totalBytes)*100;

                    Preloader_movieclip.Loader_text=Math.round((loadedBytes/totalBytes)*100)+"% Complete";

                    if (loadedBytes = totalBytes){

                    // ***************************************************************************************** **************************

                    // (loadMovie("Creative-Outrage.swf",Empty_movieclip));  remove or comment-out this line


                    }

                    else {

                    gotoAndPlay(1);

                    }

                    }


                    loader.loadClip("Creative-Outrage.swf",Empty_movieclip);

                    • 7. Re: external preloader script problem
                      kglad Adobe Community Professional & MVP

                      whoa, what's that gotoAndPlay(1)???

                       

                      that code should not be repeatedly executing.  if you have a frame loop, remove it.

                      • 8. Re: external preloader script problem
                        gotoAndExplore Level 1

                        ok, i've removed that repeating frame loop and the other code i had in the 'if' syntax, it getting a little further along the progress bar but it's still repeating though, i've tried removing else 'syntax' altogether, i've tried putting a stop(); function on the else 'syntax'. here it is again:

                         

                        var loader:MovieClipLoader = new MovieClipLoader();

                        this.createEmptyMovieClip("Empty_movieclip",1);


                        var preload:Object = new Object();

                        loader.addListener(preload);


                        preload.onLoadProgress = function (target,loadedBytes,totalBytes){

                        Preloader_movieclip.Bar_movieclip._xscale=(loadedBytes/totalBytes)*100;

                        Preloader_movieclip.Loader_text=Math.round((loadedBytes/totalBytes)*100)+"% Complete";

                        if (loadedBytes = totalBytes);

                        else {

                        stop();

                        }

                        }


                        loader.loadClip("Creative-Outrage.swf",Empty_movieclip);

                        • 9. Re: external preloader script problem
                          kglad Adobe Community Professional & MVP

                          var loader:MovieClipLoader = new MovieClipLoader();

                          this.createEmptyMovieClip("Empty_movieclip",1);


                          var preload:Object = new Object();

                          loader.addListener(preload);


                          preload.onLoadProgress = function (target,loadedBytes,totalBytes){

                          Preloader_movieclip.Bar_movieclip._xscale=(loadedBytes/totalBytes)*100;

                          Preloader_movieclip.Loader_text=Math.round((loadedBytes/totalBytes)*100)+"% Complete";

                          if (loadedBytes == totalBytes){

                          // do whatever.  loading is complete

                          }

                          }


                          loader.loadClip("Creative-Outrage.swf",Empty_movieclip);

                          • 10. Re: external preloader script problem
                            gotoAndExplore Level 1

                            woohoo! thanks i've got it displaying the gradual progress, it was missing a second '=' sign from the 'if' parameters, i've also had to put a stop(); function at the beginning of the script on frame two so it doesn't keep repeating a loop and told it to make the preloader invisible when loading completes, but now i've noticed when doing a simulation that it starts the external movie before the progress bar is full... WTH?!?!

                             

                            stop();


                            var loader:MovieClipLoader = new MovieClipLoader();

                            this.createEmptyMovieClip("Empty_movieclip",1);


                            var preload:Object = new Object();

                            loader.addListener(preload);


                            preload.onLoadProgress = function (target,loadedBytes,totalBytes){

                            Preloader_movieclip.Bar_movieclip._xscale=(loadedBytes/totalBytes)*100;

                            if (loadedBytes == totalBytes){

                            Preloader_movieclip._visible = false;

                            }

                            }


                            loader.loadClip("Creative-Outrage.swf",Empty_movieclip);

                            • 11. Re: external preloader script problem
                              kglad Adobe Community Professional & MVP

                              swf's stream.  when all the assets in frame 1 of a loading swf are loaded, frame 1 plays.  when all the assets up to frame n are loaded, the frames up to frame n play.

                               

                              to prevent this, place an empty keyframe at frame1 of the external swf and attach a stop().

                               

                              when preloading is complete and you're ready to display the loaded swf, execute a loadtarget.play()

                              • 12. Re: external preloader script problem
                                gotoAndExplore Level 1

                                still doing it, i've obviously not done it right. it put an empty frame at the beginning of the external movie with a stop(); function and here's what i've got on frame two of the preloader file:

                                 

                                stop();


                                var loader:MovieClipLoader = new MovieClipLoader();

                                this.createEmptyMovieClip("Empty_movieclip",1);


                                var preload:Object = new Object();

                                loader.addListener(preload);


                                preload.onLoadProgress = function (target,loadedBytes,totalBytes){

                                Preloader_movieclip.Bar_movieclip._xscale=(loadedBytes/totalBytes)*100;

                                if (loadedBytes == totalBytes){

                                Preloader_movieclip._visible = false;

                                }

                                }


                                loader.loadClip("Creative-Outrage.swf",Empty_movieclip);

                                loadtarget.play();

                                • 13. Re: external preloader script problem
                                  kglad Adobe Community Professional & MVP

                                  nope:

                                   


                                   

                                   

                                  stop();


                                  var loader:MovieClipLoader = new MovieClipLoader();

                                  this.createEmptyMovieClip("Empty_movieclip",1);


                                  var preload:Object = new Object();

                                  loader.addListener(preload);


                                  preload.onLoadProgress = function (target,loadedBytes,totalBytes){

                                  Preloader_movieclip.Bar_movieclip._xscale=(loadedBytes/totalBytes)*100;

                                  if (loadedBytes == totalBytes){

                                  Preloader_movieclip._visible = false;

                                  Empty_movieclip.play();

                                  }

                                  }


                                  loader.loadClip("Creative-Outrage.swf",Empty_movieclip);


                                  • 14. Re: external preloader script problem
                                    gotoAndExplore Level 1

                                    sorry, not working either, i just copied your whole last reply, minus the nope.

                                    • 15. Re: external preloader script problem
                                      kglad Adobe Community Professional & MVP

                                       


                                       

                                       

                                      stop();


                                      var loader:MovieClipLoader = new MovieClipLoader();

                                      this.createEmptyMovieClip("Empty_movieclip",1);


                                      var preload:Object = new Object();

                                      loader.addListener(preload);


                                      preload.onLoadProgress = function (target,loadedBytes,totalBytes){

                                      Preloader_movieclip.Bar_movieclip._xscale=(loadedBytes/totalBytes)*100;

                                      if (loadedBytes == totalBytes&&loadedBytes>0){

                                      Preloader_movieclip._visible = false;

                                      Empty_movieclip.play();

                                      }

                                      }


                                      loader.loadClip("Creative-Outrage.swf",Empty_movieclip);


                                      • 16. Re: external preloader script problem
                                        gotoAndExplore Level 1

                                        nope, not that either, sorry

                                        • 17. Re: external preloader script problem
                                          kglad Adobe Community Professional & MVP

                                          post a link to one of your external swf's that has the latest code.

                                          • 19. Re: external preloader script problem
                                            kglad Adobe Community Professional & MVP

                                            i'm not going to be able to help you.  sorry.

                                            • 20. Re: external preloader script problem
                                              gotoAndExplore Level 1

                                              ok, thanks for trying anyway, it's actually barely noticable when loading from the website,