14 Replies Latest reply on Feb 18, 2011 11:46 AM by kglad

    loadMovie how to know which is loaded

    juresti Level 1

      I'm loading many movies in a moan movie into mc instance name "movieHolder" I need something to happen only IF the first movie is not loaded. How can I check WHAT movie is currently loaded in movieHolder?

       

      I guess I could set / pass a varialble?

       

      Any help is appreciated!!!

        • 1. Re: loadMovie how to know which is loaded
          kglad Adobe Community Professional & MVP

          you can use the _url propery of movieclips to see what's loaded into the target movieclip.

          • 2. Re: loadMovie how to know which is loaded
            juresti Level 1

            The only way I can get the url or do anything is if the movie is loaded. I'm using loadmovie and I dont know how to know when it is loaded and then get the url and then it it is a particular url then do something.

            • 3. Re: loadMovie how to know which is loaded
              juresti Level 1

              I tried adding code to the preloader function still doesnt work.

               

               

              stop();
              // this function runs the preloader
              // it is to be used with the onEnterFrame
              // of the preloader animation
              function preloadContainer(){
                 
                  // get bytes loaded and total from container_mc
                  var bytes_loaded = movieHolder.getBytesLoaded();
                  var bytes_total = movieHolder.getBytesTotal();
                  var urlString:String = movieHolder._url
                  var filename:String = urlString.substring(urlString.lastIndexOf("/")+1, urlString.length);
                 
                  // stop and hide the movie so it wont play or
                  // be seen while progressively downloading
                  // (keep trying if it exists or not just to be sure)
                  movieHolder.stop();
                  movieHolder._visible = false;
                 
                  // if bytes_total is a valid number and greater than 0
                  if (bytes_total > 0){
                     
                      // get percent loaded
                      var percent_loaded = bytes_loaded/bytes_total;
                     
                      // update the value in the preloader
                      preloader_mc.value = percent_loaded;
                         
                      // check if preloading is complete
                      if (percent_loaded == 1){
                         
                          // play and show the container clip
                          movieHolder.gotoAndStop(1);
                          movieHolder._visible = true;
                         
                         trace(movieHolder._url);
                          //trace(filename);
                          if (filename == "ShopOutsideAnim01.swf") {
                          trace("nooo");
                          }
                          else {
                              attachMovie("buttonblank", "butt_blank", 2, {_x: 22, _y: 5});
                          butt_blank._alpha = 50;
                          }

               

                          // remove the preloader movie clip
                          preloader_mc.removeMovieClip();
                         
                          // delete the onEnterFrame event handler running this function
                          delete onEnterFrame;
                      }
                  }
              }

              • 4. Re: loadMovie how to know which is loaded
                kglad Adobe Community Professional & MVP

                if you want to know which, if any, movie is loaded into a target movieclip, use the _url property of that target movieclip.  if you want to know something else, what is that you want to know?

                • 5. Re: loadMovie how to know which is loaded
                  juresti Level 1

                  Well I want to attach a button only if what is loaded is not a particular movie but when I use the _url property it does not seem to be accessing the movie name because it is being loaded

                  • 6. Re: loadMovie how to know which is loaded
                    juresti Level 1

                    trace(movieHolder._url);

                     

                    I get this:

                    file:///C|/MyProjects/Modules/Fishing%20Module/ForScorm/MovieHolder.swf

                     

                    I want this:

                    file:///C|/MyProjects/Modules/Fishing%20Module/ForScorm/ShopOutsideAnim01.swf

                    • 7. Re: loadMovie how to know which is loaded
                      kglad Adobe Community Professional & MVP

                      the _url property is what it is.

                       

                      if you movieHolder._url = your _level0 swf, nothing's been loaded yet.  in particular,  file:///C|/MyProjects/Modules/Fishing%20Module/ForScorm/ShopOutsideAnim01.swf has NOT been loaded yet.

                       

                      and loading is asynchronous.  just because you execute a loadMovie() method, you wouldn't expect loading to complete instantly and therefore the _url property won't change instantly.

                      • 8. Re: loadMovie how to know which is loaded
                        juresti Level 1

                        yea but what I dont get is why if I have a preloader for the clip being loaded and when its done I trace(movieHolder._url) I still dont get the name of the loaded movie.

                         

                         

                        if (percent_loaded == 1){
                                   
                                    // play and show the container clip
                                    movieHolder.gotoAndStop(1);
                                    movieHolder._visible = true;
                                    trace(movieHolder._url);

                        • 9. Re: loadMovie how to know which is loaded
                          juresti Level 1

                          I really don't even need to do this to make things work now. The thing is I still don't get why I preload it with a preloader once totalbytes=bytes loaded I ask for url of movieHolder and it gives me the name of the main file I am in. Not the file that was loaded into movieHolder.

                          • 10. Re: loadMovie how to know which is loaded
                            kglad Adobe Community Professional & MVP

                            show your loadMovie() and code that repeatedly calls preloadContainer()

                            • 11. Re: loadMovie how to know which is loaded
                              juresti Level 1

                              Main Movie First Frame:

                               

                              stop();

                               

                              // this function runs the preloader

                               

                              // it is to be used with the onEnterFrame

                               

                              // of the preloader animation

                               

                              function preloadContainer(){

                               

                               

                               

                                  // get bytes loaded and total from container_mc

                               

                                  var bytes_loaded = movieHolder.getBytesLoaded();

                               

                                  var bytes_total = movieHolder.getBytesTotal();

                               

                               

                               

                               

                               

                                  // stop and hide the movie so it wont play or

                               

                                  // be seen while progressively downloading

                               

                                  // (keep trying if it exists or not just to be sure)

                               

                                  movieHolder.stop();

                               

                                  movieHolder._visible = false;

                               

                               

                               

                                  // if bytes_total is a valid number and greater than 0

                               

                                  if (bytes_total > 0){

                               

                               

                               

                                      // get percent loaded

                               

                                      var percent_loaded = bytes_loaded/bytes_total;

                               

                               

                               

                                      // update the value in the preloader

                               

                                      preloader_mc.value = percent_loaded;

                               

                               

                               

                                      // check if preloading is complete        if (percent_loaded == 1){

                               

                               

                               

                                          // play and show the container clip

                               

                                          movieHolder.gotoAndStop(1);

                               

                                          movieHolder._visible = true;

                               

                               

                               

                                          // remove the preloader movie clip

                               

                                          preloader_mc.removeMovieClip();

                               

                               

                               

                                          // delete the onEnterFrame event handler running this function

                               

                                          delete onEnterFrame;

                               

                                      }

                               

                                  }

                               

                              }

                               

                               

                              first frame inside preloader_mc:

                              var value = 0;
                              onEnterFrame = function(){
                                  //update % text
                                  if (value) loaded_txt.text = Math.round(100*value) + "%";
                              }

                               

                               

                              Main Movie First Frame layer below the preloader:

                               

                              var swfURL:String = "ShopOutsideAnim01.swf";

                              startPreload(swfURL);

                               

                              function startPreload(swfURL){
                                 
                                  // use loadMovie to load the swf url into container_mc
                                  movieHolder.loadMovie(swfURL);
                                 
                                  // attach the preloader animation
                                  // this will be removed when preloading is complete
                                  attachMovie("preloader anim", "preloader_mc", 500, {_x:393, _y:286});
                                 
                                  // set the onEnterFrame event to call preloadContainer
                                  onEnterFrame = preloadContainer;
                              }

                               

                              Message was edited by: juresti

                              • 12. Re: loadMovie how to know which is loaded
                                kglad Adobe Community Professional & MVP

                                you have to wait until the loaded swf is initialized.  either use the onLoadInit() method of the moviecliploader class or delete your onEnterFrame loop one loop after you're doing now.

                                1 person found this helpful
                                • 13. Re: loadMovie how to know which is loaded
                                  juresti Level 1

                                  How would I delete my onEnterFrame loop one loop after I'm doing now? Is that possible by just moving delete onEnterFrame?

                                  • 14. Re: loadMovie how to know which is loaded
                                    kglad Adobe Community Professional & MVP

                                    var deleteLoop:Boolean;

                                    juresti wrote:

                                     

                                    Main Movie First Frame:

                                     

                                    stop();

                                     

                                    // this function runs the preloader

                                     

                                    // it is to be used with the onEnterFrame

                                     

                                    // of the preloader animation

                                     

                                    function preloadContainer(){

                                     

                                     

                                     

                                        // get bytes loaded and total from container_mc

                                     

                                        var bytes_loaded = movieHolder.getBytesLoaded();

                                     

                                        var bytes_total = movieHolder.getBytesTotal();

                                     

                                     

                                     

                                     

                                     

                                        // stop and hide the movie so it wont play or

                                     

                                        // be seen while progressively downloading

                                     

                                        // (keep trying if it exists or not just to be sure)

                                     

                                        movieHolder.stop();

                                     

                                        movieHolder._visible = false;

                                     

                                     

                                     

                                        // if bytes_total is a valid number and greater than 0

                                     

                                        if (bytes_total > 0){

                                     

                                     

                                     

                                            // get percent loaded

                                     

                                            var percent_loaded = bytes_loaded/bytes_total;

                                     

                                     

                                     

                                            // update the value in the preloader

                                     

                                            preloader_mc.value = percent_loaded;

                                     

                                     

                                     

                                            // check if preloading is complete        if (percent_loaded == 1){

                                     

                                     

                                     

                                                // play and show the container clip

                                     

                                                movieHolder.gotoAndStop(1);

                                     

                                                movieHolder._visible = true;

                                     

                                     

                                     

                                                // remove the preloader movie clip

                                     

                                                preloader_mc.removeMovieClip();

                                     

                                     

                                                // delete the onEnterFrame event handler running this function

                                    if(deleteLoop){

                                                delete onEnterFrame;

                                    trace(movieHolder._url);

                                    }

                                    deleteLoop=true;

                                            }

                                     

                                        }

                                     

                                    }

                                     

                                     

                                    first frame inside preloader_mc:

                                    var value = 0;
                                    onEnterFrame = function(){
                                        //update % text
                                        if (value) loaded_txt.text = Math.round(100*value) + "%";
                                    }

                                     

                                     

                                    Main Movie First Frame layer below the preloader:

                                     

                                    var swfURL:String = "ShopOutsideAnim01.swf";

                                    startPreload(swfURL);

                                     

                                    function startPreload(swfURL){
                                       
                                        // use loadMovie to load the swf url into container_mc
                                        movieHolder.loadMovie(swfURL);
                                       
                                        // attach the preloader animation
                                        // this will be removed when preloading is complete
                                        attachMovie("preloader anim", "preloader_mc", 500, {_x:393, _y:286});
                                       
                                        // set the onEnterFrame event to call preloadContainer
                                        onEnterFrame = preloadContainer;
                                    }

                                     

                                    Message was edited by: juresti

                                    1 person found this helpful