8 Replies Latest reply on Dec 3, 2011 9:07 AM by kglad

    Nested Frames and gotoAndStop

    Krautinator

      I have a very specific AS2 parent/child movie clip issue, if anyone here can help out.


      I have a main Character movie clip which contains as nested frames each profile of the Character (front,back,left,etc). Within each of these child profile MC frames, animations for those profiles are further nested in frames.


      Then, essentially I have movement code as part of the key listener:


      switch(Key.getCode())

                {

                          case 87:

                          Character._y -= 10;

                          Character.gotoAndStop('Back');

                          Character.gotoAndStop('walk');

                          break;

       

       

                          case 83:

                          Character._y += 15;

                          Character.gotoAndStop('Front');

                          Character.Front.gotoAndStop('walk');

                          break; 

                }

      And later code to reset to the character's resting frame after key release:

       

      switch(Character._currentFrame)

                {

                          case 5:

                          Character.gotoAndStop('Back');

                          break;

       

                          case 1:

                          Character.gotoAndStop('Front');

                          break;

       

                }


      The problem is that when I try to Character.gotoAndStop('Front'); after key release, flash thinks, you're already on the Front frame (because the walk animation is a child of that MC and is already playing). Therefore the walk animation just keeps playing after the key has been released.


      Is there an easy, one-off way to fix this?


      Thanks in advance for any help.

        • 1. Re: Nested Frames and gotoAndStop
          kglad Adobe Community Professional & MVP

          apply a stop() to the child movieclip, if that's what you want:

           

              Character.gotoAndStop('Front');

          Character.childmovieclip.stop();

          • 2. Re: Nested Frames and gotoAndStop
            Krautinator Level 1

            Unfortunately, that doesn't work.

             

            Flash essentially is saying: I am still on the Front frame, so there's no need to do anything else.

             

            So the previously called gotoAndStop for the walk animation just keeps going.

             

            Hope that makes sense.

            • 3. Re: Nested Frames and gotoAndStop
              kglad Adobe Community Professional & MVP

              is there a child movieclip that keeps playing when you're on the Front frame?  if yes, what's the instance name of that child movieclip and do you want that child movieclip to stop playing?

              • 4. Re: Nested Frames and gotoAndStop
                Krautinator Level 1

                Well, as I laid out before I have a main Character movie clip, under which are nested MCs with different profile views on each frame, and under those MCs are further nested profile animations in the same manner.

                 

                Essentially, when a key is pressed, I want to activate the walk animation.  This requires first going to the Character's "Front" frame, and further to the "walk" animation frame nested under "Front".

                 

                When the key is released, I naturally want the walk animation to stop.  I am unsure how to accomplish this.  Is there some way to reference this clip heirarchy in order to make Flash show only the "Front" frame and not the animations underneath it?  As it currently functions, the code I pasted before does not accomplish this.  The walk animation continues to play even after key being released.

                • 5. Re: Nested Frames and gotoAndStop
                  iFlashAppsToo Level 3

                  let's say characterMc has 4 frames: up down left right... frame down has a movieclip named  frontMc... frontMc has 2 frames: run walk... each of these frames have a movieclip that animates the action... these animation movieclips can have the same name since they are on different frames- for example, each named "anim"... now on key release you can characterMc.frontMc.anim.stop() and it wouldn't matter if you're on frame walk or frame run

                   

                  or

                   

                  you can give frontMc a third frame: run walk blank... frame blank is empty... now on key release you can characterMc.frontMc.gotoAndStop("blank")

                  • 6. Re: Nested Frames and gotoAndStop
                    kglad Adobe Community Professional & MVP

                    i just told you how to do that. you failed to understand that advice because you don't understand flash.

                     

                    you need to understand how flash handles your setup so you can solve this problem (which i already explained how to do).

                     

                    let's start with, "This requires first going to the Character's "Front" frame, and further to the "walk" animation frame nested under "Front"."

                     

                    Character has a keyframe "Front".  that makes sense to flash (and those of us that understand flash).  'and further to the "walk" animation frame nested under "Front".'  does not make sense. 

                     

                    there must be a child movieclip on Character's keyframe "Front" and that movieclip can have keyframes including one labeled "walk".  That child movieclip's instance name is critical to handling your issue.  i used childmoviecip in the code i suggested but you should give this movieclip an instance name and use that instead.

                     

                    using that child movieclip's instance name, you can control that child movieclip using dot notation like i suggested:

                     

                    Character.childmovieclip.stop();

                     

                    or, if you want to direct childmovieclip to one of its keyframes (eg, standstill), use:

                     

                    Character.childmovieclip.gotoAndStop("standstill"); 

                    1 person found this helpful
                    • 7. Re: Nested Frames and gotoAndStop
                      Krautinator Level 1

                      If I completely understood flash, I wouldn't be on here asking for help (apparently wasting your time).

                       

                      I'll give what you stated a shot.