6 Replies Latest reply on Jul 25, 2011 10:09 PM by kglad

    Referencing Frame label children

    Krautinator

      Hi all

       

      I have this issue with action script I've written (AS2), it is simple movement code for an on-screen character.

       

      I have a character set up with a hierarchy of nested movie clips and frame labels.

       

      Main character MC (1 frame, no label)

      |

      Front/Side/Back pose MCs (several separate frames, with labels, no animations)

      |

      Animation MCs for single pose (e.g. idle, walk, crouch, etc) (several separate frames, with labels)

       

       

      I want to reference the child frame labels with gotoAndStop ('Front.walk'), or similar...

       

      Here is the code I have now:

       

      keyListener = new Object();

       

      keyListener.onKeyDown = function ()

      {

      switch(Key.getCode())

      {

      case 87:

      Character._y -= 10;

      Character.gotoAndStop('Back.walk');

      break;

       

      case 83:

      Character._y += 10;

      Character.gotoAndStop('Front.walk');

      break;

      }

      }

       

      Key.addListener(keyListener);

       

      Now... this actually works... sort of.

       

      The problem is, as soon as the character moves one direction and changes to the desired pose, when I try to go the opposite direction... the pose doesn't change to the opposite direction frame label. So it only works once, and stays on that child frame label.

       

      Is there a problem with the way I'm referencing the child frame labels?

        • 1. Re: Referencing Frame label children
          kglad Adobe Community Professional & MVP

          do you have a frame label named "Back.walk" or do you have a movieclip Back nested in Character and Back has a frame labeled "walk" or something else?

          1 person found this helpful
          • 2. Re: Referencing Frame label children
            Krautinator Level 1

            The character MC has several pose MCs nested inside, all on different frames, with corresponding frame labels.  Those pose MCs (Front, Back, Side, etc) then have their own animation MCs nested inside them, which are also on different frames, with corresponding frame labels (walk, run, crouch, etc).

            • 3. Re: Referencing Frame label children
              Krautinator Level 1

              I think it may be that it's just nested too deep, because here's what happens:

               

              If I have both gotoAndStop actions reference 2 frame labels deep (e.g. Front.walk, Back.walk, etc), only one animation will work.

               

              If I have one gotoAndStop action reference 1 frame label deep (Back), and one reference 2 frame labels deep (Front.walk), both will work, however, the Back MC will stay permanantly after that key is pressed, so basically the character can still move around the screen, but only the Back MC is shown no matter what key is pressed.

               

              Really frustrating.

              • 4. Re: Referencing Frame label children
                kglad Adobe Community Professional & MVP

                apply a goto method to the movieclip you want to direct and use the frame label to specify where you want the movieclip to go.  so, for example, if you have

                 

                Character that you want to direct to "front_frame" and on "front_frame" you have a movieclip

                Front and you want to direct Front to a frame labeled "walk" on Front's timeline, use:

                 

                Character.gotoAndStop("front_frame");

                Character.Front.gotoAndPlay("walk");

                1 person found this helpful
                • 5. Re: Referencing Frame label children
                  Krautinator Level 1

                  Thanks, that seemed to solve that problem... however it seems to have created a new one... now the walk animation won't stop!

                  • 6. Re: Referencing Frame label children
                    kglad Adobe Community Professional & MVP

                    apply a stop() or a gotoAndStop() where needed.

                     

                    p.s.  please mark helpful/correct responses.

                    1 person found this helpful