2 Replies Latest reply on Apr 17, 2006 7:54 AM by aniebel

    target path issue

    aniebel Level 2
      Can anyone tell me why this function is not working from the main timeline (frame 1)? The movie has a stop action on frame 2 and on the main movie is the MC with an instance name of "newsNav_mc". In that MC is a frame label "openR" and it has a tween from that frame to frame 34 which has a stop on it.

      It's not advancing the movie clip to "openR". What have I done wrong?


      onEnterFrame = function () {
      if (this._currentframe == 2) {
      this.newsNav_mc.gotoAndPlay("openR");
      }
      if (this.newsNav_mc._currentframe == 34) {
      delete onEnterFrame;
      }
      };
        • 1. Re: target path issue
          Level 7
          aniebel,

          > Can anyone tell me why this function is not working from
          > the main timeline (frame 1)?

          I'll try.

          > The movie has a stop action on frame 2

          Okay, so that means the SWF will hit frame 1 first, execute the code you
          put there, then advance to frame 2 and stop. Frame 1's code sets in motion
          an onEnterFrame event, which fires at approximately the speed of your
          movie's frame rate. So ...

          > onEnterFrame = function () {
          > if (this._currentframe == 2) {

          ... when the playhead advances to frame 2 and stops, the above condition
          will be true -- perhaps for a long time. At the default 12fps, your
          onEnterFrame event is firing approximlately once every 88 milliseconds (12
          times a second).

          So what are you asking Flash to do so often? The following line.

          > this.newsNav_mc.gotoAndPlay("openR");

          So the playhead inside newsNav_mc is almost constantly being sent to
          that "openR" frame. It never has the chance to actually *play* that
          timeline, because every time it starts -- every 88 milliseconds, perhaps! --
          you're telling it to go back to the "openR" label and start again.

          Why not try something like this?

          // on frame 2 of the main timeline
          this.stop();
          this.newsNav_mc.gotoAndPlay("openR");
          this.newsNav_mc.onEnterFrame = function () {
          if (this._currentframe == 34) {
          trace("arrived at frame 34");
          delete onEnterFrame;
          }
          };

          Do you see how that's different?


          David
          stiller (at) quip (dot) net
          Dev essays: http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: target path issue
            aniebel Level 2
            Yes, that makes total sense. I was having trouble before calling the mc from another frame but I must have had something else going on.

            Thanks!