2 Replies Latest reply on Jul 5, 2010 2:04 PM by fulfordsupply

    where to put gotoAndPlay within a function

    fulfordsupply

      for reference: fulfordsupply.com/home.htm
      I will try to communicate this as simply as possible.

      On my first frame, I have:

      6 buttons (p1 through p6)

      A holder mc_holder, which holds mc_pages, {a movie clip that shows 6  pages (each their own movie clip, page1 though page6) tweened across  the screen, made to look as if the pages are being "flipped" through}

      The following code (thanks to DAWSONK):

      Code:
      stop();
      var _holder = mc_holder.mc_pages;
      var picked;
      p1.goal = 1;
      p1.onRelease = goPage;
      p2.goal = 10;
      p2.onRelease = goPage;
      p3.goal = 20;
      p3.onRelease = goPage;
      p4.goal = 30;
      p4.onRelease = goPage;
      p5.goal = 40;
      p5.onRelease = goPage;
      p6.goal = 50;
      p6.onRelease = goPage;

      function goPage() {
           _holder.goal = this.goal;
           _holder.onEnterFrame = function() {
                if (this.goal>this._currentframe) {
                     this.gotoAndStop(this._currentframe+1);
                } else if (this.goal<this._currentframe) {
                     this.gotoAndStop(this._currentframe-1);
                } else {
                     delete this.onEnterFrame;
                }
           };
      }

      }

      On each of the 6 pages, I have some animation.

       

      The problem is, as soon as the movie loads, ALL these animations begin  to play.  I am looking for a solution so that the animations will not  play until the page is viewed.

       

      I am thinking I can put a stop on the first frame of each page, and a  frame label ("go") on the second frame.

       

      Can I add this (my knowledge is limited but say... gotoAndPlay (go") )  to the code shown above? I have tried messing around with it but have  not yet had any results.

       

       

      Thanks in advance.
        • 1. Re: where to put gotoAndPlay within a function
          jimfid45 Level 1

          Hi I created something which I believe is what you are trying to do and based on 3 pages not 6.

           

          First the code in frame 1 ( open up the Actions panel ) and only frame 1:  ( Paste this code in on frame 1 as the very last step then test movie )

           

          stop();

           

          btn_home.addEventListener(MouseEvent.MOUSE_DOWN, home_page);
          btn_pg1.addEventListener(MouseEvent.MOUSE_DOWN, page_1);
          btn_pg2.addEventListener(MouseEvent.MOUSE_DOWN, page_2);

           

          function home_page(event:MouseEvent):void {
              gotoAndPlay(1);
              stop();
          }

           

          function page_1(event:MouseEvent):void {
              gotoAndPlay(2);
              stop();
          }

           

          function page_2(event:MouseEvent):void {
              gotoAndPlay(3);
              stop();
          }

           

          Create a Flash document and in the first frame place 3 buttons on stage  ( I dragged then from Window -> Components-> then button)

           

          Name the first button (instance name) btn_home

           

          Name second button btn_pg1

           

          Nmae 3rd button btn_pg2

           

          On frame 1  create some text named "Home"  (the home page)

           

          Insert 2 more frames so you now have 3 frames total carrying the buttons across to the 3rd frame.

           

          In frame 2 change the text to read 'Page 1" away from "Home"

           

          in frame 3 change the text to read "Page 2" away from "Home"

           

          This does work.

          Jim

          • 2. Re: where to put gotoAndPlay within a function
            fulfordsupply Level 1

            Hey, thanks for the quick response.  I'm really stuck on this and can't go further with my project.

             

            However I should have mentioned, I'm working with actionscript 2.  I tried this in 2 and had a bunch of errors... then again in 3, and had a different set of errors.  What script did you write this in?