4 Replies Latest reply on Jun 22, 2007 1:07 PM by Newsgroup_User

    gotoAndStop at a frame in external swf

    kingmonkey Level 1
      Hi

      I have for example 3 btns in the main movie, a container with instance name container and an external swf with an intro and 3 labels to match the 3 btns. How do I gotoAndStop to the relevant frame within the externally loaded movie?

      Code I'm using is;

      Code:
      on (release) {
      _root.container.loadMovie("portfolio_cats.swf");
      gotoAndStop("_root.container.cat2");
      }


      Where am I going wrong? as the external movie just plays at the start??

      Thanks in advance
      Wayne
        • 1. Re: gotoAndStop at a frame in external swf
          Level 7
          your external movie must load completely before you can send commands to
          it... your code tries to access it immediately after asking it to begin
          loading...

          kingmonkey wrote:
          > Hi
          >
          > I have for example 3 btns in the main movie, a container with instance name
          > container and an external swf with an intro and 3 labels to match the 3 btns.
          > How do I gotoAndStop to the relevant frame within the externally loaded movie?
          >
          > Code I'm using is;
          >
          > Code:
          > on (release) {
          > _root.container.loadMovie("portfolio_cats.swf");
          > gotoAndStop("_root.container.cat2");
          > }
          >
          >
          > Where am I going wrong? as the external movie just plays at the start??
          >
          > Thanks in advance
          > Wayne
          >
          • 2. Re: gotoAndStop at a frame in external swf
            Level 7
            Wayne,

            > How do I gotoAndStop to the relevant frame within the
            > externally loaded movie?

            The key is to wait until that movie has loaded, before you start trying
            to navigate it.

            > on (release) {
            > _root.container.loadMovie("portfolio_cats.swf");
            > gotoAndStop("_root.container.cat2");
            > }

            Yup. That SWF *starts* to load, and then you immediately tell it to go
            to a frame that mostly likely isn't available yet. In addition, you're not
            quite feeding the gotoAndStop() function correctly. The parameter needs to
            be either a number (a frame number) or a string (a frame label).

            on (release) {
            _root.container.loadMovie("portfolio_cats.swf");
            _root.container.gotoAndStop("cat2");
            }

            ... that's assuming your label name is "cat2". See how I've applied the
            gotoAndStop() directly to the container clip itself? That's because movie
            clip symbols are actually instances of the MovieClip class, and if you look
            up the "MovieClip class" entry in the ActionScript 2.0 Language Reference in
            the Help files, you'll see that one of the available methods is
            MovieClip.gotoAndStop(). Methods are object "functions"; they're "verbs" of
            an object, the things it can do. Properties are characteristics of the
            object, and events are things the object can react to.

            But even the above revised code won't do it. You'll need to make sure
            that external SWF is loaded first. Here's a short article on a couple
            different ways to ascertain that:

            http://www.quip.net/blog/2006/flash/how-to-tell-when-external-swf-loaded/


            David Stiller
            Adobe Community Expert
            Dev blog, http://www.quip.net/blog/
            "Luck is the residue of good design."


            • 3. Re: gotoAndStop at a frame in external swf
              Level 7
              there you go being thorough again... *s*

              David Stiller wrote:
              > Wayne,
              >
              >> How do I gotoAndStop to the relevant frame within the
              >> externally loaded movie?
              >
              > The key is to wait until that movie has loaded, before you start trying
              > to navigate it.
              >
              >> on (release) {
              >> _root.container.loadMovie("portfolio_cats.swf");
              >> gotoAndStop("_root.container.cat2");
              >> }
              >
              > Yup. That SWF *starts* to load, and then you immediately tell it to go
              > to a frame that mostly likely isn't available yet. In addition, you're not
              > quite feeding the gotoAndStop() function correctly. The parameter needs to
              > be either a number (a frame number) or a string (a frame label).
              >
              > on (release) {
              > _root.container.loadMovie("portfolio_cats.swf");
              > _root.container.gotoAndStop("cat2");
              > }
              >
              > ... that's assuming your label name is "cat2". See how I've applied the
              > gotoAndStop() directly to the container clip itself? That's because movie
              > clip symbols are actually instances of the MovieClip class, and if you look
              > up the "MovieClip class" entry in the ActionScript 2.0 Language Reference in
              > the Help files, you'll see that one of the available methods is
              > MovieClip.gotoAndStop(). Methods are object "functions"; they're "verbs" of
              > an object, the things it can do. Properties are characteristics of the
              > object, and events are things the object can react to.
              >
              > But even the above revised code won't do it. You'll need to make sure
              > that external SWF is loaded first. Here's a short article on a couple
              > different ways to ascertain that:
              >
              > http://www.quip.net/blog/2006/flash/how-to-tell-when-external-swf-loaded/
              >
              >
              > David Stiller
              > Adobe Community Expert
              > Dev blog, http://www.quip.net/blog/
              > "Luck is the residue of good design."
              >
              >
              • 4. Re: gotoAndStop at a frame in external swf
                kingmonkey Level 1
                Hi

                Thanks for your posts and explaining why my code wasn't working, I understand know, and thanks for the link, I can now figure out what I need to do to make it work, I'm quite new to flash and actionscript, so finding good learning resources is very helpful.

                Cheers
                Wayne