7 Replies Latest reply on Feb 25, 2012 7:34 PM by Cabbibo

    gotoAndPlay("go"); not working...

    Cabbibo

      so I am working on a very simple program whose main frames action is as follows:

       

      //Begin

       

      _global.depth = 4;

      _global.clicktimer = 0;

      _global.timer = 0;

      _global.fast = 2;

       

       

      var isMouseDown:Boolean = false;

      this.onMouseDown = function() {

          isMouseDown = true;

      };

      this.onMouseUp = function() {

          isMouseDown = false;

      };

       

       

       

       

       

       

      onEnterFrame = function(){

                _global.shapeI._xscale += _global.fast;

                _global.shapeI._yscale += _global.fast;

                _global.shapeII._xscale += _global.fast;

                _global.shapeII._yscale += _global.fast;

                _global.shapeIII._xscale += _global.fast;

                _global.shapeIII._yscale += _global.fast;

                _global.shapeVI._xscale += _global.fast;

                _global.shapeVI._yscale += _global.fast;

                _global.shapeV._xscale += _global.fast;

                _global.shapeV._yscale += _global.fast;

                _global.shapeVI._xscale += _global.fast;

                _global.shapeVI._yscale += _global.fast;

                _global.shapeVII._xscale += _global.fast;

                _global.shapeVII._yscale += _global.fast;

                _global.shapeVIII._xscale += _global.fast;

                _global.shapeVIII._yscale += _global.fast;

                _global.shapeIX._xscale += _global.fast;

                _global.shapeIX._yscale += _global.fast;

                _global.shapeX._xscale += _global.fast;

                _global.shapeX._yscale += _global.fast;

       

       

       

       

       

                _global.timer ++;

                _global.clicktimer ++;

       

                if (isMouseDown && _global.clicktimer >= 8) {

       

                          var randomShape:Number = Math.round(Math.random()*6)+1;

                          var thisMC:MovieClip = this.attachMovie("shape" +randomShape+"_mc", "target1_mc", _global.depth);

                          thisMC._x=Stage.width/2;

                          thisMC._y=Stage.height/2;

                          thisMC._xscale=3;

                          thisMC._yscale=3;

       

       

                          _global.shapeX.removeMovieClip();

                          _global.shapeX = _global.shapeIX;

                          _global.shapeIX = _global.shapeVIII;

                          _global.shapeVIII = _global.shapeVII;

                          _global.shapeVII = _global.shapeVI;

                          _global.shapeVI = _global.shapeV;

                          _global.shapeV = _global.shapeVI;

                          _global.shapeVI = _global.shapeIII;

                          _global.shapeIII = _global.shapeII;

                          _global.shapeII = _global.shapeI;

                          _global.shapeI = thisMC;

       

                          _global.timer = 0;

                          _global.clicktimer=0;

                          _global.depth ++;

       

       

             

          }

       

       

                if (_global.timer == 50){

       

       

                          var randomShape:Number = Math.round(Math.random()*6)+1;

                          var thisMC:MovieClip = this.attachMovie("shape" +randomShape+"_mc", "target1_mc", _global.depth);

                          thisMC._x=Stage.width/2;

                          thisMC._y=Stage.height/2;

                          thisMC._xscale=3;

                          thisMC._yscale=3;

       

       

                          _global.shapeX.removeMovieClip();

                          _global.shapeX = _global.shapeIX;

                          _global.shapeIX = _global.shapeVIII;

                          _global.shapeVIII = _global.shapeVII;

                          _global.shapeVII = _global.shapeVI;

                          _global.shapeVI = _global.shapeV;

                          _global.shapeV = _global.shapeVI;

                          _global.shapeVI = _global.shapeIII;

                          _global.shapeIII = _global.shapeII;

                          _global.shapeII = _global.shapeI;

                          _global.shapeI = thisMC;

       

                          _global.timer = 0;

                          _global.depth ++;

       

       

       

                          }

       

      };

       

       

      gotoAndPlay("go");

       

       

      //End

       

       

       

       

      the frame is labeled go and basically I am trying to add a simple preloader before, which right now only has the action

       

      gotoAndPlay("go");

       

      however when I publish it, or just run it, the program doesn't start. Any thoughts?!? I feel real silly for not being able to figure it out myself, but i've tried basically everything...

      including switching the "go" for the frame that the action script is on (4 in this case)

        • 1. Re: gotoAndPlay("go"); not working...
          prodigalmaster Level 2

          how many frames are there?

          Are there 2 frames and you want it to go the the second (go) ?

           

          I noticed you didn't have stop(); in this frame. Maybe that has something to do with it. But yes it is odd gotoAndPlay("go"); isnt working, only thing I can think is if you didnt name the frame correctly, make sure you dont use " " and do it on the actual frame not a movieclip or something.

          • 2. Re: gotoAndPlay("go"); not working...
            Ned Murphy Adobe Community Professional & MVP

            YOu should try eliminating most of the other code (just comment it out) and get the gotoAndPlay("go") working first.  Then reintroduce the rest of the code segements gradually to see if one of them is causing a problem.

            • 3. Re: gotoAndPlay("go"); not working...
              Cabbibo Level 1

              So there are 4 frames, I have put a trace("frame #") on each frame, and it seems as though only the 1st and 4th frame are being read, which leads me to believe that the first gotoAndPlay is working, but the one that is self referencing  is not. I have just changed to gotoAndPlay(4); (frame where the program is) rather then the label, so I can figure this out.

               

              is there somewhere where i should put a stop(); command on the main set of code?

              • 4. Re: gotoAndPlay("go"); not working...
                Cabbibo Level 1

                so I commented out everything,

                now all there is is

                 

                //onframe1:

                stop();

                gotoAndPlay(4);

                trace("frame 1");

                 

                //onframe2

                trace("frame 2");

                 

                //onframe3

                trace("frame 3");

                 

                //onframe4

                stop();

                trace("frame 4");

                gotoAndPlay(4);

                 

                 

                when I run the output is

                 

                frame 1

                frame 4

                frame 1

                frame 4

                frame 1

                frame 4

                frame 1

                frame 4

                frame 1

                frame 4

                 

                 

                etc.

                 

                 

                 

                EDIT: I have also discovered a really fun game of trying to scroll up on the output window faster then new out put is created. Its like trying to run up an escalator thats going down at 24 fps

                • 5. Re: gotoAndPlay("go"); not working...
                  Ned Murphy Adobe Community Professional & MVP

                  When you are in frame 1 and tell it to gotoAndPlay(4), it does that.  When you are in frame 4 and tell it to gotoAndPlay(4), it is already in frame 4 and the stop() is already used up, so it plays, which sends it to frame 1... and rinse and repeat

                   

                  You won't see the traces in frames 2 and 3 because it never hits those frames.

                   

                  You might try using gotoAndStop() instead if there is no real intention of playing when you get to specific frames.

                  • 6. Re: gotoAndPlay("go"); not working...
                    Ned Murphy Adobe Community Professional & MVP

                    As for the other posting you started for this, your title for it is dead on correct... you cannot do that.  You cannot get it to output the consecutive frame 4's unless you remove the stop and put your gotoAndPlay(4) in frame 5.  An alternative would be to place an onEnterFrame function in frame 4 and have that constantly trace the "frame 4" output

                     

                    Constantly telling something to go to a frame it is already in is not going to make it replay the frame over and over.

                    1 person found this helpful
                    • 7. Re: gotoAndPlay("go"); not working...
                      Cabbibo Level 1

                      thanks so much for the help Ned, I really didn't understand what gotoAndPlay(); actually meant. Now I do!