8 Replies Latest reply on Mar 6, 2007 9:07 AM by Mister Peanut

    External SWF

    Mister Peanut Level 1
      Hello, I have a simple problem, I think. I have a button that, when pressed, loads an external swf called, Staff.swf, into a loader named myloaderBG_mc. I would like to go directly to frame 5 in this swf, and not just to frame 1. I thought this would be the code I use:

      lilwat.onRelease = function(){
      textClear();
      backgroundMain._visible = false;
      hand._visible = false;
      myloaderBG_mc.loadMovie("Staff.swf",5);
      myloader_mc.unloadMovie();
      }

      Is it more complex than this?

      I thought this was the way, but I must be missing something really simple...

      Cheers,

      P
        • 1. Re: External SWF
          kglad Adobe Community Professional & MVP
          yes, it's more complex. if you can add code to Staff.swf, that would be the simplest way to procede. if you can't add code to Staff.swf you must use preloader code or the onLoadInit() method of the moviecliploader class listener to direct Staff.swf's target movieclip to frame 5 when loading is complete and Staff.swf is initialized.
          • 2. Re: External SWF
            Mister Peanut Level 1
            I can add code to Staff.swf. Hope it's not too difficult....
            • 3. Re: External SWF
              Mister Peanut Level 1
              Hi Kglad,

              I also have buttons on the same page that load the same swf into myloaderBG_mc, but that go to different frames. Will this complicate things?

              Cheers,

              P
              • 4. Re: External SWF
                kglad Adobe Community Professional & MVP
                no, you can add code to the first frame of Staff.swf that directs Staff.swf to check for a variable's value that will direct Staff.swf to the frame set by that variable's value.

                then in your button you will defined the variable and set it's value:

                for example:

                • 5. Re: External SWF
                  Mister Peanut Level 1
                  Hi kglad,

                  This is exactly what I'm looking for, thanks! Just one last question, though; should I use _parent instead of _root? The reason I ask is because I have one more level above my "main" swf. (I made an introduction swf that loads my entire site, which in turn, loads each of the pages).


                  and why, in my "main swf" do I use _root?
                  _root.frameToDisplay=5;
                  Is it necessary to put in? I understand why you would put it in "Staff.swf", but not the main swf. I'm just curious because I'm not so good with AS and would like to understand it well.

                  Thanks for your help,

                  P
                  • 6. Re: External SWF
                    kglad Adobe Community Professional & MVP
                    _root in your main swf refers to its main timeline. _root in Staff.swf refers to the same timeline AFTER Staff.swf is loaded into your main swf.

                    you can use a relative path (like _parent) but it becomes a little tougher to determine if that's going to work correctly and may depend upon whether your button is a true button or movieclip button.
                    • 7. Re: External SWF
                      Mister Peanut Level 1
                      Hi Kglad,

                      Your code works great the first time, but when I go back to my homepage, and click the link once more, it takes me to frame 1 of Staff.swf. I also have a lockroot=true function in my Staff.swf... maybe this has something to do with it? Not too sure why. If you have any ideas on why, please let me know. Otherwise, thanks a million for helping me this far!

                      Cheers,

                      P
                      • 8. Re: External SWF
                        Mister Peanut Level 1
                        Oh! I think I figured it out.... I put _parent into the code in Staff.swf, and it seems to work!

                        Thanks again,

                        P