8 Replies Latest reply on Jun 15, 2006 9:42 PM by kglad

    reversing a clip on a button click

    sooz_e
      Hi,

      What I want to happen here is that the page go through its load animation backwards (to unload the page) when the user clicks a button on the nav menu.

      It kinda worked once or twice, but in the if {} suddenly jumped to main time line from the page clip and only a couple frames worth were reversed.

      a trace() after "_parent.gotoAndStop(70)" shows the _parent._currentframe as 70.
      breakpoints while debugging don't seem to get close to the if{} now? It is always skipping from " _parent.onEnterFrame = function() {" directly to " _root.gotoAndPlay(_global.pageToPlay);" Breakpoints on and inside the if are not hit?

      Can anyone help?

      Sue

      on (release) {
      _global.pageToPlay = 2;//main page
      _parent.gotoAndStop(70);
      _parent.onEnterFrame = function() {
      if (_parent._currentframe > 1) {
      this.prevFrame();
      }
      };
      _root.gotoAndPlay(_global.pageToPlay);
      }
        • 2. Re: reversing a clip on a button click
          sooz_e Level 1
          Hmmm...I see how I wouldn't want that function attached to onEnterFrame outside this if{}. Thank you : )

          This didn't fix whatever the trouble is though? The breakpoint stops at the _parent.onEnterFrame, but even a trace before the if{} doesn't print to the output window? It is as if the onEnterFrame has already happened and so the function doesn't get called.

          Thanks for taking a look,

          Sue
          • 3. Re: reversing a clip on a button click
            kglad Adobe Community Professional & MVP
            _root and _parent in your onRelease handler are differenet, aren't they? what's the output window show if you use the following:

            • 4. Re: reversing a clip on a button click
              sooz_e Level 1
              Yes,

              Root and parent are different, and parent is different depending on which instance of the websites basic page the navigation button is clicked on.

              a _level0.servPage _level0 //mainPage button clicked on the servicePage instance of pageTemplate_mc
              a _level0.mainPage _level0 //mainPage button clicked on the mainPage instance of pageTemplate_mc

              b, inside the function, never gets hit.

              I was using _parent instead of this inside the function for awhile. In some rendition of the code a few frames played backward, but on the root timeline rather than on the page clip time line. Does the reference change after the gotoAndStop? Or does it stay the same as long as the code is executing from button instance onRelease?

              Thanx again for helping out :)
              • 5. Re: reversing a clip on a button click
                kglad Adobe Community Professional & MVP
                what happens to _parent on its frame 70?:

                p.s. movieclip references within the button handler don't change with frame changes, but do change within other handlers like your enterFrame handler.
                • 6. Re: reversing a clip on a button click
                  sooz_e Level 1
                  There are about 84 frames in _parent. It is about 70 frames of rectangles, logos, and buttons flying into position. A few frames after 70 I use attachMovie and a switch to select the correct content layout, and assign the correct dynamic text to that layout. There are some frames w/ script in them after 70. In the rendition of code that was sort of working (incorrectly), I got the idea it might not be a good idea to reverse to the frame with that script in it. Beyond that 70 was a random choice.

                  re: p.s. ---so it should be this inside the onEnterFrame function and _parent outside the function?

                  Thanx,

                  Sue
                  • 7. Re: reversing a clip on a button click
                    sooz_e Level 1
                    Hey,

                    I got this to work!

                    Couldn't have done it w/o the delete clause in the if/else, so thanks again for your help!

                    Playing in reverse was slower than forward, so I moved the code to frame 35 from 70 in order to shorten the reverse.
                    In case anyone else is struggling with this or cares to, the code is attached.

                    My code is getting pretty dispersed throughout varioous clips' timelines. Could code like this even be managed from the main timeline frame 2?

                    Sue
                    • 8. Re: reversing a clip on a button click
                      kglad Adobe Community Professional & MVP
                      the code can be used from any frame (with the correct path) and at any time (as long as the objects referenced exist at the time the code executes).