30 Replies Latest reply on Feb 5, 2010 7:39 AM by kglad

    AS2 Question/Problem..

    y2kmfic

      I have a swf where I'm calling two external swf files.  These external swf files also load data from an xml file.  The problem is that the first external swf file that I load is the only one that loads.  Well.. the other swf does load, but it loads the first xml file loaded.  I've tried adding each swf to their own frame and holder, then unload.. still no luck.  I can run my swf, click the button to load mc1.swf and it loads fine.  I then click the button to unload mc1/load mc2, but the xml data form mc1 is loaded.  If I close the player, and launch mc2, it loads fine, but now mc1 will not load!!  AGG.. this is driving me crazy.

       

      Here's the file structure I'm using:

      root/files/main.swf  -  my swf file that loads the other files

      root/files/mc1.swf

      root/files/mc2.swf

      root/files/mc1data/info.xml

      root/files/mc2data/info.xml

       

      The thing is I can't change the path, or file name for mc1/2's xml file, as I don't have the source.

       

      I really appreciate all the assistance I can get.

       

      TIA!!

        • 1. Re: AS2 Question/Problem..
          kglad Adobe Community Professional & MVP

          if you open an html file that embeds mc1.swf what path does it use to access its xml file?

          • 2. Re: AS2 Question/Problem..
            stellarinterface

            What is the ActionScript code you are using to load the two external swf files? I usually call the original swf the 'shell' (root) swf. If you plan to load more than one swf into the shell swf, then you need to specify the level that they should be loaded into.

             

            Are you using loadMovie() or attachMovie()? I only ask because attachMovie will only allow you to work with a single document.

             

            If you want to load the external swf into a movie clip reference, you would specify the instance of the movie clip after the swf name. You could essentially create two empty movie clips in your library (drag these empty proxy movie clips to your stage) and just give them instance names and linkage properties of "_level1" and "_level2". You might have to play around with the x and y coordinates to make them appear where you want.

             

            loadMovie("root/files/mc1.swf", "_level1");

            loadMovie("root/files/mc2.swf", "_level2");

            • 3. Re: AS2 Question/Problem..
              y2kmfic Level 1

              Here is the complete script I'm testing with.  I've tried loadmovie, loadurl, loadclip.. all work for the first swf loaded, but each swf I try to load after that just reverts to the original.  This code doesn't have any unloads, but I tried unloadmovie, unloadclip and others.

               

              About the "root", yeah that was a bit missleading.  I'm going to publish this to CDROM, and want to leave the root as clean as possible.

               

              stop();
              function loadSWFFile(which:String) {

               

              this.createEmptyMovieClip("image_mc", this.getNextHighestDepth());
              var mclListener:Object = new Object();
              mclListener.onLoadInit = function(target_mc:MovieClip) {
              target_mc._width = 800;
              target_mc._height = 400;
              target_mc.moveTo(0, 0);
              };
              var image_mcl:MovieClipLoader = new MovieClipLoader();
              image_mcl.addListener(mclListener);
              image_mcl.loadClip(which, image_mc);
              }

               

              btn1.onRelease = function(){
                  loadSWFFile("mc1.swf");
              }

               

              btn2.onRelease = function(){
                  loadSWFFile("mc2.swf");
              }

              • 4. Re: AS2 Question/Problem..
                stellarinterface Level 1

                Are you trying to load the two external swfs at the same time, or just one at a time? If one at a time, you might have to use unloadMovie on the 1st movie before loading the 2nd one - try putting it in your 2nd function above the load mc2.swf line. For example:

                unloadMovie(clipOrLevelName);

                or

                clipOrLevelName.unloadMovie();

                 

                Does that work?

                • 5. Re: AS2 Question/Problem..
                  kglad Adobe Community Professional & MVP

                  you have some problems with your code.

                   

                  use:

                   

                   

                  stop();

                   

                  this.createEmptyMovieClip("image_mc",this.getNextHighestDepth());

                   

                  var mclListener:Object = new Object();

                   

                  mclListener.onLoadInit = function(target_mc:MovieClip) {

                      target_mc._width = 800;

                      target_mc._height = 400;

                  }

                  var image_mcl:MovieClipLoader = new MovieClipLoader();

                   

                  image_mcl.addListener(mclListener);

                   

                  function loadSWFFile(which:String) {

                   

                      image_mcl.loadClip(which,image_mc);

                   

                  }

                   

                  btn1.onRelease = function() {

                   

                      loadSWFFile("mc1.swf");

                   

                  };

                   

                  btn2.onRelease = function() {

                   

                      loadSWFFile("mc2.swf");

                   

                  };
                  • 6. Re: AS2 Question/Problem..
                    y2kmfic Level 1

                    No, the unload has no effect.  I've tried many different ways.  There's something screwy with these external .swf files and the way they're loading the .xml data.  In the same example above, I've tested with simple .swf movie clips, and it works fine.

                    • 7. Re: AS2 Question/Problem..
                      kglad Adobe Community Professional & MVP

                      again, you have problems with your code.  and again, you need to know the xml path used by the loaded swfs.

                      • 8. Re: AS2 Question/Problem..
                        y2kmfic Level 1

                        @kglad..

                         

                        Where is the problem in the code posted above?

                         

                        The path to the xml is also posted above (files/mc1data/info.xml)

                         

                        TIA

                        • 9. Re: AS2 Question/Problem..
                          stellarinterface Level 1

                          I did this in the past, and I vaugely remember having to change the path to the XML so that it was a relative path to the swf, as opposed to a relative path to the root swf. Have you tried that?

                          • 10. Re: AS2 Question/Problem..
                            y2kmfic Level 1

                            @stellarinterface..

                             

                            I think you're right.  Unfortunately, I don't have access to the

                            source for the external swf files.

                             

                            Thanks.

                            • 11. Re: AS2 Question/Problem..
                              kglad Adobe Community Professional & MVP

                              that's not the path used by the swfs.   when you run one of the swfs by itself (without loading it into another swf), what path is used to retrieve the xml?

                               

                              and here's the code you should be using:

                               

                              stop();

                               

                              this.createEmptyMovieClip("image_mc",this.getNextHighestDepth());

                               

                              var mclListener:Object = new Object();

                               

                              mclListener.onLoadInit = function(target_mc:MovieClip) {

                                  target_mc._width = 800;

                                  target_mc._height = 400;

                              }

                              var image_mcl:MovieClipLoader = new MovieClipLoader();

                               

                              image_mcl.addListener(mclListener);

                               

                              function loadSWFFile(which:String) {

                               

                                  image_mcl.loadClip(which,image_mc);

                               

                              }

                               

                              btn1.onRelease = function() {

                               

                                  loadSWFFile("mc1.swf");

                               

                              };

                               

                              btn2.onRelease = function() {

                               

                                  loadSWFFile("mc2.swf");

                               

                              };

                              • 12. Re: AS2 Question/Problem..
                                stellarinterface Level 1

                                If it's worth it, it might be worth looking into using a swf decompiler... Although warning: many of the free decompilers out there have malware on them. There are some safe ones, but I forget the names. I've had to use them before when I had my fla files corrupted. This has happened to me a few times over the years, and there was no way to get my own source code other than to decompile my swfs. That's my last suggestion, good luck.

                                • 13. Re: AS2 Question/Problem..
                                  y2kmfic Level 1

                                  In the /files folder, there are only two .xml files.  One in

                                  /files/mc1data/ and one in /files/mc2data/.

                                   

                                  I tried the above below, and there is no difference... the first movie

                                  loads fine, but not the second.  For example, when the app loads, and

                                  I press btn1, then mc1.swf loads fine.  Now if I press btn2, mc1.swf

                                  still loads.

                                   

                                  Thanks.

                                  • 14. Re: AS2 Question/Problem..
                                    kglad Adobe Community Professional & MVP

                                    you don't understand the issue.

                                     

                                    create a new folder somewhere.  drag mc1.swf to the folder.  open mc1.swf in your flash player.  there should be problems because no xml file is loaded.

                                     

                                    now, move one of the xml files to that new folder.  retry.  there will probably still be errors because the xml file needs to be in a subfolder of that new folder.  what subfolder does that xml file need to be in for mc1.swf to work correctly when it's placed in that new folder.

                                    • 15. Re: AS2 Question/Problem..
                                      y2kmfic Level 1

                                      I did the following..

                                       

                                      moved mc1.swf in to a /junk folder.. I ran mc1.swf .. it runs, but has

                                      errors because it can't find the info.xml file

                                      moved info.xml to the /junk folder.. ran mc1.swf, and again runs, but

                                      with errors because info.xml is in the wrong folder

                                      created a /junk/mc1data folder and placed the info.xml in that folder

                                      and ran mc1.swf.. it runs without error.

                                       

                                      Thanks.

                                      • 16. Re: AS2 Question/Problem..
                                        kglad Adobe Community Professional & MVP

                                        then you'll need to edit the swf.  it's using its _url property to construct the path to the xml file.

                                         

                                        that _url property changes when that swf is loaded into another swf.  there's no work-around unless you knew the code loading the xml then we could over-ride that code from your loading swf.

                                        • 17. Re: AS2 Question/Problem..
                                          y2kmfic Level 1

                                          I've been thinking about this and trying other things.  I agree that a

                                          path is getting messed up somewhere.  The question is, why does the

                                          first mc always load just fine?  The path is correct then.  It's like

                                          it isn't TOTALLY being unloaded.

                                          • 18. Re: AS2 Question/Problem..
                                            kglad Adobe Community Professional & MVP

                                            either the 2nd load is being retrieved from cache (if you're testing in a browser) or the same xml is loading no matter which loads first.

                                            • 19. Re: AS2 Question/Problem..
                                              y2kmfic Level 1

                                              Thanks, kglad..

                                               

                                              I'm testing the the flashplayer, as ultimately that's how I want to

                                              publish it (as .exe).

                                               

                                              Is there a way to completely reset the main swf file to it's original state?

                                               

                                              As an FYI, the external swfs are page flippling books from page-flip.com.

                                               

                                              TIA.

                                              • 20. Re: AS2 Question/Problem..
                                                kglad Adobe Community Professional & MVP

                                                you can reset everything by reloading:

                                                 

                                                loadMovieNum(this._url,0);  // don't put this in frame 1 of your main timeline unless it's triggered by user input.

                                                 

                                                p.s.  zip and attach one of those swfs.  (are the swfs the same except they use different xml files?)

                                                • 21. Re: AS2 Question/Problem..
                                                  y2kmfic Level 1

                                                  Thanks for all the suggestions, kglad.  I'll try anything.

                                                   

                                                  I tried the loadMovieNum("main.swf",0) and your line below on a btn

                                                  click, an neither work.  The damn thing still loads the first .swf!

                                                   

                                                  TIA

                                                  • 22. Re: AS2 Question/Problem..
                                                    kglad Adobe Community Professional & MVP

                                                    zip and attach one of those swfs.  (are the swfs the same except they use different xml files?)

                                                    • 23. Re: AS2 Question/Problem..
                                                      y2kmfic Level 1

                                                      Kglad..

                                                      I can't attach the swf as I think it will violate their TOS agreement.

                                                      They do have a demo version available at page-flip.com.

                                                       

                                                      The app is very easy to use.. import PDF, publish to swf or .exe and your done.

                                                       

                                                      To answer your question.. the swf I'm using are similar, but not 100%

                                                      identical.

                                                       

                                                      Thanks for the help.

                                                      • 24. Re: AS2 Question/Problem..
                                                        kglad Adobe Community Professional & MVP

                                                        it can't violate tos to share a swf or you couldn't use the swf online.  or, that's a pretty stupid tos.

                                                        • 25. Re: AS2 Question/Problem..
                                                          y2kmfic Level 1

                                                          I agree.  I wasn't 100% sure, but just wanted to be safe. Anyway, I've

                                                          attached two different swf projects.

                                                           

                                                          Thanks again!!

                                                          • 26. Re: AS2 Question/Problem..
                                                            y2kmfic Level 1

                                                            Here are the files.

                                                             

                                                            files.rar.zip .. nice.

                                                            • 27. Re: AS2 Question/Problem..
                                                              kglad Adobe Community Professional & MVP

                                                              it looks like there should be instructions for how to use these page turn swfs when loaded into another swf.  aren't you supposed to use a query string when calling the swf?

                                                              • 28. Re: AS2 Question/Problem..
                                                                y2kmfic Level 1

                                                                There are no instructions for this.  I've contacted their support dept

                                                                and was told that I should publish to .exe.  I can do that, but I need

                                                                to have a single window open (the main .swf/exe).

                                                                 

                                                                There are no strings or variables you pass to the swf.

                                                                 

                                                                In my head, I keep going back to the fact that each of them load fine

                                                                inside of another swf.  So why can't you load one, close it, then load

                                                                the other? <--rhetorical question

                                                                 

                                                                Thanks!

                                                                • 29. Re: AS2 Question/Problem..
                                                                  kglad Adobe Community Professional & MVP

                                                                  use an as3 file to open your swfs.

                                                                  • 30. Re: AS2 Question/Problem..
                                                                    kglad Adobe Community Professional & MVP

                                                                    you have the fla?  isn't it as3?

                                                                     

                                                                    and what's the path to the xml files?