8 Replies Latest reply on Dec 31, 2012 7:28 AM by Ned Murphy

    loading external SWF

    TheScarecrow Level 1

      I have this code to load an external SWF.  The external SWF is loads an XML file and creates a slideshow from the XML file.  The movie I am loading it into has the following code on a frame and has about 20 layers to it.  It all seems to execute but I dont see the external movie and I am not sure why.  Anyone see a problem with this code or know why it doesnt show up? Thanks

       

      CODE:

      this.createEmptyMovieClip("slideshow_mc", 2000);

      var my_listener:Object = new Object();

       

       

      my_listener.onLoadComplete = function(target_mc:MovieClip) {

          target_mc._x = 50;

                target_mc._y = 50;

      }

       

       

      my_listener.onLoadProgress = function(target_mc:MovieClip) {

                trace(target_mc.getBytesLoaded() + " out of " + target_mc.getBytesTotal());

      }

       

       

      var my_loader:MovieClipLoader = new MovieClipLoader();

      my_loader.addListener(my_listener);

      my_loader.loadClip("slideshow-endsample.swf", slideshow_mc);

      this.slideshow_mc.loadMovie("slideshow-endsample.swf", _level0.slideshow_mc);

        • 1. Re: loading external SWF
          Ned Murphy Adobe Community Professional & MVP

          The last two lines you show are could represent a conflict of interests. 

           

          my_loader.loadClip("slideshow-endsample.swf", slideshow_mc);

          this.slideshow_mc.loadMovie("slideshow-endsample.swf", _level0.slideshow_mc);

           

          Both of those lines are for loading an external file, and it appears they are both trying to load the same one.  Since you are set up for the MovieClipLoader, which is the better option if you need to know when loading is complete, first try getting rid of the last line and see how things go.

          • 2. Re: loading external SWF
            TheScarecrow Level 1

            ok So I have this code now that works but it replaces my whole original movie and I am not sure why.  If I remove the last line.  I nothing happens.

             

            CODE:

            this.createEmptyMovieClip("slideshow_mc", 2000);

            var my_listener:Object = new Object();

             

             

            my_listener.onLoadComplete = function(target_mc:MovieClip) {

                target_mc._x = 50;

                      target_mc._y = 50;

            }

             

             

            my_listener.onLoadProgress = function(target_mc:MovieClip) {

                      trace(target_mc.getBytesLoaded() + " out of " + target_mc.getBytesTotal());

            }

             

             

            var my_loader:MovieClipLoader = new MovieClipLoader();

            my_loader.addListener(my_listener);

            my_loader.loadClip("slideshow-endsample.swf", _level0.slideshow_mc);

             

             

            _root.loadMovie("slideshow-endsample.swf", _level0.slideshow_mc);

            • 3. Re: loading external SWF
              Ned Murphy Adobe Community Professional & MVP

              I already indicated that you are doing two different loadings with the code you show.  Use one method or the other, but not both.  If you want to use loadMovie, then try using just....

               

                  this.createEmptyMovieClip("slideshow_mc", 2000);

                  loadMovie("slideshow-endsample.swf", this["slideshow_mc"]);

               

              The reason you replace your original movie is because you are using the loadMovie method (_root.loadMovie... a method of the _root object), which will replace whatever you have in the _root with the loaded movie.

               

              But using loadMovie eliminates your ability to track the loading progress and manipulation of position once the movie is loaded.  If those are necessary features, then use the MovieClipLoader approach instead.

              • 4. Re: loading external SWF
                Ned Murphy Adobe Community Professional & MVP

                To use the MovieClipLoader approach you only need to use...

                 

                this.createEmptyMovieClip("slideshow_mc", 2000);

                var my_listener:Object = new Object();

                 

                my_listener.onLoadComplete = function(target_mc:MovieClip) {

                    target_mc._x = 50;

                    target_mc._y = 50;

                }

                 

                my_listener.onLoadProgress = function(target_mc:MovieClip) {

                    trace(target_mc.getBytesLoaded() + " out of " + target_mc.getBytesTotal());

                }

                 

                var my_loader:MovieClipLoader = new MovieClipLoader();

                my_loader.addListener(my_listener);

                my_loader.loadClip("slideshow-endsample.swf", this["slideshow_mc"]);

                • 5. Re: loading external SWF
                  Ned Murphy Adobe Community Professional & MVP

                  The last thing I will offer for the moment... if you are loading a file that makes use of _root references, that might be the reason you have problems when you load it into another file into a movieclip.  Within that loaded file you should be setting the _lockroot property to true so that it does not look to the main file for its _root references.

                  • 6. Re: loading external SWF
                    TheScarecrow Level 1

                    if I want to turn this line my_loader.loadClip("slideshow-endsample.swf", this["slideshow_mc"]); to where the "Slideshow-endsample.swf" is a variable name like currentArray.  How would I do that?  cause substituting currentArray doesnt seem to work.

                    • 7. Re: loading external SWF
                      TheScarecrow Level 1

                      ok I got it.  Thanks.

                      my_loader.loadClip(currentArray+".swf", this["slideshow_mc"]);

                      • 8. Re: loading external SWF
                        Ned Murphy Adobe Community Professional & MVP

                        You're welcome