6 Replies Latest reply on Apr 17, 2006 10:36 AM by rodolfo1216

    triggering actions using frame labels

    rodolfo1216 Level 1
      Not sure how to do this one: I want to trigger an action when the playhead reaches a certain labeled frame. I can make it work using:
      if (_currentframe == 10){
      dothis;
      }

      but I anticipate moving things around in the timeline so I would rather have the action triggered when the playhead reaches a certain frame label. I tried using something like:
      if (frameLabel == "myframenamehere") {
      dothis;
      }

      but that doesn't work. Any help much appreciated!

      Michael
        • 1. Re: triggering actions using frame labels
          Level 7
          Michael,

          > Not sure how to do this one: I want to trigger an action
          > when the playhead reaches a certain labeled frame.

          The is a common request. Unfortunately, Flash simply doesn't support
          this feature.

          > I tried using something like:
          > if (frameLabel == "myframenamehere") {
          > dothis;
          > }
          >
          > but that doesn't work.

          I'm always curious how it happens that people just "try using"
          something. I suppose there's no harm in that -- and sure, experimentation
          may just teach a person something new -- but the practice seems odd to me as
          as a general approach. Not saying this is *your* general approach, just
          that I see this a lot in the forums.

          Since you're dealing with movie clips, here, your best bet is to read up
          on the "MovieClip class" entry of the ActionScript Language Reference.
          Classes define objects, and just about everything in ActionScript is an
          object. Movie clips are defined by the MovieClip class. Their
          characteristics are listed under the Properties summary, things they can do
          are listed under the Methods summary, and things they can react to are
          listed under the Event summary.

          There simply isn't a frameLabel property, or a _framelabel property, or
          any other property to do with frames.


          David
          stiller (at) quip (dot) net
          Dev essays: http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: triggering actions using frame labels
            rodolfo1216 Level 1
            Thanks again David for your help. Even though I can't do things exactly has I want to, it's good to know that I can stop going down the wrong road in my attempts. I will take a look at the MovieClip class.

            Michael
            • 3. Re: triggering actions using frame labels
              babo_ya Level 3
              You could create a global variable and assign the frame label in different frames.
              And use that global to see which frame you are at.

              • 4. Re: triggering actions using frame labels
                rodolfo1216 Level 1
                Hmmm..not quite sure what you mean. Can you elaborate?
                • 5. Re: triggering actions using frame labels
                  Level 7
                  >> You could create a global variable and assign the
                  >> frame label in different frames.
                  >> And use that global to see which frame you are at

                  > Hmmm..not quite sure what you mean. Can you elaborate?

                  This is a classic example of "if the environment doesn't offer what you
                  want, then roll your own." You could put a small bit of code in each frame
                  that contains a label. This code, in each of its places, would do nothing
                  more than set the value of a variable that is available globally. You could
                  store the variable as a property of the _global object, for example, or
                  simply place it in the main timeline and path to it via _root.

                  // Frame 1 code
                  _global.currentFrame = "";

                  // Frame 20, which happens to have
                  // a frame label "cupcakes"
                  _global.currentFrame = "cupcakes";

                  Now, instead of checking for a movie clip property, such as ...

                  if (myClip._currentframe == 5) {}

                  ... you can check the value of the global variable ...

                  if (_global.currentFrame == "cupcakes") {}


                  David
                  stiller (at) quip (dot) net
                  Dev essays: http://www.quip.net/blog/
                  "Luck is the residue of good design."


                  • 6. Re: triggering actions using frame labels
                    rodolfo1216 Level 1
                    Yup. That did it. Works perfectly. What do you know - there is a workaround.

                    Thanks again for the help.

                    Michael