4 Replies Latest reply on Dec 4, 2012 11:07 AM by TimJaramillo

    Controlling a symbol's timeline

    19cbren76

      Here is what I would like to do:

       

      on click play "circle"

       

      Then is user clicks again:

      on click playReverse "circle"

       

      Issue is I'm using the symbol as the botton to trigger the it's animation. So how do I use the same symbol to trigger the animation in reverse.

       

      Thanks!

        • 1. Re: Controlling a symbol's timeline
          TimJaramillo Level 4

          Hi 19, you can acheive this by setting a variable at the Stage.compositionReadyEvent:

           

          sym.direction = "forward";

           

          Then on your button click, check that variable:

           

          if(sym.getComposition().getStage().direction == "forward"){

               //play forward

               sym.play();

              

               // switch var for next click

               sym.getComposition().getStage().direction = "reverse";

          }else{

               // play reverse

               sym.playReverse();

           

               // switch var for next click

               sym.getComposition().getStage().direction = "forward";

          }

          • 2. Re: Controlling a symbol's timeline
            19cbren76 Level 1

            Hey Tim,

             

            Thanks for your reply.

             

            Due to my ignorance with code, I might be confused with what you wrote for me...

             

            I'm looking to play the timline inside the symbol forward on click and then in reverse once clicked again. Using the same button for both actions.  The symbol is sitting on the stage.  Symbol's name is "circle".

             

            Thanks again!

            • 3. Re: Controlling a symbol's timeline
              19cbren76 Level 1

              Ha, got it to work.  The code needed to be on the button inside the symbol!

               

              Question though, why did it need to be insid ethe symbol and not at the root of the stage?

               

              Thanks man you rock ha.

              • 4. Re: Controlling a symbol's timeline
                TimJaramillo Level 4

                Glad you got it working!

                 

                It's all about scope- depending on your setup (where your symbol is, where your code is) you need to target methods (like play) and variables, differently.