19 Replies Latest reply on Feb 14, 2014 9:09 AM by XhebbsX

    Play Previous Label

    Liam@AESSEAL

      Is there any way to play from the previous label in a timeline?

      ie: if i have 10 labels in the timeline and have 2 buttons to move forwards and backwards through them, then the "backwards" button would need to play from the previous label each time it is pressed. Play reverse is no good as the animation i have will play in reverse.

        • 1. Re: Play Previous Label
          resdesign Adobe Community Professional & MVP

          Yes. You can use a similar code as this one:

          Call your labels with numbers like L0, L1, L2, L3, tec...

           

          then

          sym.$('btnNext').click(function(){

               i++;

               sym.play('L' + i);

               // write code to stop at the end (max numb of your labels for example)

           

          });

           

          sym.$('btnPrev').click(function(){

               i--;

               sym.play('L' + i);

               if (i<0){

               i=0;

               }

          });

          1 person found this helpful
          • 2. Re: Play Previous Label
            elainecc Adobe Employee

            I personally don't like the ActionScript-like incrementation of variable names.  Instead, I generally will stick all of my labels into an array and step through the array.

             

            Thanks,

             

            -Elaine

            • 3. Re: Play Previous Label
              resdesign Adobe Community Professional & MVP

              Elaine,

              Like you said, it is a matter of preference (and sometimes habbits!) as you said!

              • 4. Re: Play Previous Label
                resdesign Adobe Community Professional & MVP

                Actually after reflection, your way is probably more flexible!

                • 5. Re: Play Previous Label
                  jomo5280 Level 1

                  @resdesign - how do you ensure this method plays within a symbol?

                  I can't get mine to play - probably a path issue?

                  thanks!

                  • 6. Re: Play Previous Label
                    resdesign Adobe Community Professional & MVP

                    Are you playing the timeline of a symbol?

                    If so use:

                     

                    sym.getsymbol('nameofSymbolhere').play('L' +i);

                     

                    Are the play buttons in the symbol or somewhere else?

                    • 7. Re: Play Previous Label
                      jomo5280 Level 1

                      Awesome! thank you!

                      • 8. Re: Play Previous Label
                        Liam@AESSEAL Level 1

                        Hmm, im no web coder and i thought it maybe a little more simple than this, im an AE user and the most of my coding has been done in DVD architecture, is there a way to add a number to say a variable each time the forward button is clicked? then when the backward button is clicked it reads the variable and plays the corrisponding label?

                        • 9. Re: Play Previous Label
                          resdesign Adobe Community Professional & MVP

                          Liam, this is what i++ and i-- do. Every time you click on the button next, i is incremented by +1 and the button prev by -1.

                          If you are using an array for the labels as Elaine mentioned then you can limit the click to the length on the label in the next and even reset it there to 0

                          On next button

                          if (i>myLabels.length){

                          // do something like return the variable to zero creating a loop or stop there.

                          }

                           

                          On previous button

                          if (myLabels<0){

                          // stop there or return the variable to zero or go the the last label to create a loop.

                          }

                          • 10. Re: Play Previous Label
                            jomo5280 Level 1

                            Actually, i want to set up a button, on rollover, that will play to a specific frame.

                            (basically a frame that has a glow effect)

                             

                            this is what i have - but it doesn't seem to work"

                            on main timeline - on btn_1 i have this set for on mouseover:

                             

                            sym.getsymbol('btn_1').play('glow');

                            • 11. Re: Play Previous Label
                              JRHall

                              @resdesign

                               

                              I am trying to set up a similar system and I am still very green with code.

                               

                              I already have my labels with a number so I think this technique would work fine for me (it doesn't need to be particularly flexible).

                               

                              My question is, where do I put this code?

                               

                              And, is i++/i-- just creating a number? And if so, can I use that number in multiple actions?

                              For example: when I click my "FWD" button can I say go to "label"[i] and play "symbolname"[i] with the understanding that both the label and symbol are numbered the same?

                              • 12. Re: Play Previous Label
                                resdesign Adobe Community Professional & MVP

                                I have since this post simplified the system.

                                The easiest is to set an array with your labels. That way you can give them more meaningful names, which can be helpful.

                                Setup the array like so:

                                var myStops =['red','white', 'blue, 'green'];

                                Then you var use the same kind of code for your buttons.

                                I++;

                                Is the shorthand for adding 1 so if you start at 0, next value of i is 1, next is 2, etc...

                                Remember an array starts at 0.

                                 

                                So if you want to okay a label on the timeline it will be:

                                 

                                sym.play(myStops[i]);

                                O

                                In a symbol

                                sym.getSymbol('symbolName').play(myStops[i]);

                                 

                                If you have text, caption or some other text you could also set the array to contain your text and it will change on the click event as well.

                                • 13. Re: Play Previous Label
                                  resdesign Adobe Community Professional & MVP

                                  Sorry typing on iPhone can be challenging, use minuscule i for the var

                                  i++;

                                   

                                  Variables are case sensitive. Just keep it consistent.

                                  • 14. Re: Play Previous Label
                                    JRHall Level 1

                                    Thanks, but where exactly do I put the array code?

                                     

                                    Sorry, I've come to Edge as an animator rather than a coder. Still very much learning

                                    • 15. Re: Play Previous Label
                                      JRHall Level 1

                                      Ok, nevermind that last question.

                                       

                                      I have the code in and almost working.

                                       

                                      I am now having a slight inconsistency issue.

                                      When I click forward, sometimes the symbols play from the start, sometimes they play from the middle and sometimes they are stopped at the end of their animation.

                                      When I click back, they sometimes play from the start, sometimes they don't play.

                                       

                                      Here is the code I have:

                                       

                                      // Array for my Timeline labels

                                      var myLabels = ['Pn1','Pn2','Pn3','End'];

                                       

                                       

                                      //Array for my symbols

                                      var myPanels = ['Panel1','Panel2','Panel3'];

                                       

                                       

                                      // Initial setting of 'i'

                                      i=0;

                                       

                                       

                                      // For forward button click

                                      sym.$('FWD').click(function(){

                                                i++;

                                         sym.play(myLabels[i]);

                                         sym.getSymbol(myPanels[i]).play(0);

                                      });

                                       

                                       

                                      // For backward button click

                                      sym.$('BACK').click(function(){

                                                i--;

                                                if (i<0){

                                                           i=0;

                                                }

                                         else{

                                                sym.play(myLabels[i]);

                                                sym.getSymbol(myPanels[i]).play(0);

                                                }

                                      });

                                       

                                       

                                      Thanks for all your help so far...

                                      • 16. Re: Play Previous Label
                                        hemanthR Adobe Employee

                                        Might be the symbols are all autoplaying ?

                                        Add a stop on 0th second trigger for the symbols so that they start playing when the button is clicked.

                                        If adding stop does not help can you share files?

                                        • 17. Re: Play Previous Label
                                          JRHall Level 1

                                          Thanks but I seem to have conquered it.

                                           

                                          I removed the stop action at the end of the symbol timelines and that did the trick.

                                          • 18. Re: Play Previous Label
                                            resdesign Adobe Community Professional & MVP

                                            Awesome.

                                            I do not know how your project is set up but I now changed a few things.

                                            For example I hide the left button (previous  or back)at start and in code when i==0 and on the right button (next) when it reaches the end so that no click action can be done. This way I does not increment for sure and the user has a visual telling him there is nothing left to see on next and nothing left to see when he goes back to the first slide.

                                            Hope this makes sense.

                                            • 19. Re: Play Previous Label
                                              XhebbsX Level 1

                                              Hi,

                                               

                                              Maby you are still looking for a solution to this issue?!?

                                               

                                              The following will do the trick if your labels are all on the main timeline (as i understand they are from your original post).

                                               

                                              PS: It is important that you put a stop trigger after each label so the timeline does not continue. This also works for mobile devices on swipe...

                                               

                                              Back button

                                              Action -> click: sym.playReverse("position");

                                               

                                              Forward button:

                                              Action -> click: sym.play("position");