16 Replies Latest reply on Sep 6, 2013 9:57 AM by Agapyla

    How to replay animation interactively

    Agapyla Level 1

      For example I have some animation being played and stopped at some point. I want to click smth on screen to replay it again. What are my best ways to do it?

        • 1. Re: How to replay animation interactively
          resdesign Adobe Community Professional & MVP

          Use something like 2 states:  on off

          you can use setVariable and getVariable

          you can use a flag like this too on your click event.

           

          var onoff = true;

          if (onoff){

          // play action

          onoff=false;

          }else

          {

          // stop action

          onoff=true;

          }

          • 2. Re: How to replay animation interactively
            AMULI Level 4

            Hi Agapyla,

             

            <yourButton>'s click event handler : sym.getSymbol( <yourAnimation>).play(0);

             

            Gil

            • 3. Re: How to replay animation interactively
              Agapyla Level 1

              trying to understand this...

              may be is there a simple sample?

              • 4. Re: How to replay animation interactively
                AMULI Level 4

                Hi Agapyla,

                 

                Here it is, with a play_btn symbol allowing (on click) to replay an upDown symbol (that has autoPlay property set to true, so that it plays one first time automatically).

                 

                Downloadable example here : https://app.box.com/s/je5do3wciq8o212f5v4w

                 

                Once you understand the principle, you can go deeper with the following thread (and downloadable example) where the same symbol is instantiated three times and clicking on one of the two in the down state plays reverse (down) the one in the up state, before playing (up) the one clicked :

                 

                http://forums.adobe.com/message/5410456

                 

                Gil

                1 person found this helpful
                • 5. Re: How to replay animation interactively
                  Agapyla Level 1

                  this is working!

                  thank))

                   

                  the understanding of your second sentense takes a time..

                  • 6. Re: How to replay animation interactively
                    AMULI Level 4

                    Great !

                    the understanding of your second sentense takes a time..

                     

                    It's always difficult to describe by text the behavior of an app (and for this reason, sometimes difficult to help people asking, as they do not formulate completely what they are trying to make !).

                     

                    And being french, surely my english does not follow the simpliest path

                     

                    Gil

                    • 7. Re: How to replay animation interactively
                      Agapyla Level 1

                      And today I finally got some error:

                       

                      var onoff = true;

                      if (onoff){

                      // play action

                      onoff=false;

                      }else

                      {

                      // stop action

                      onoff=true;

                      }//set the value of a Symbol variable

                      sym.setVariable("//get the value of a Symbol variable

                      var myVariable = sym.getVariable("myVariableName");

                      ", "variableValue");

                       

                      oh my God

                      it says - syntax error at line 10

                       

                      any help??

                      • 8. Re: How to replay animation interactively
                        AMULI Level 4

                        Salut Stéphane,

                         

                        Tu as cliqué une première fois sur le bouton d'insertion du fragment Ecrire une variable (en vert).

                         

                        Puis myVariableName (l'emplacement du premier paramètre de setVariable) étant sélectionné, tu as cliqué sur le bouton d'insertion du fragment Obtenir une variable (en bleu).

                         

                        //set the value of a Symbol variable

                        sym.setVariable("//get the value of a Symbol variable

                        var myVariable = sym.getVariable("myVariableName");

                        ", "variableValue");

                         

                        Tout ce qui suit // jusqu'au prochain retour chariot est éliminé. Donc ton code recherchera une variable de nom (entre guillemets) var myVariable = sym.getVariable(, qui n'est pas un identifiant autorisé (à cause des espaces, du =, du point et de la parenthèse).

                         

                        Et après cette chaîne, l'analyseur attend une virgule avant la valeur à affecter à la variable.

                         

                        Il y a effectivement une erreur de syntaxe

                         

                        Gil

                        • 9. Re: How to replay animation interactively
                          Agapyla Level 1

                          hello again

                          I am not Stéphane and cannot speak French

                          i tried google translate but..

                           

                          my 10th line is

                          sym.setVariable("//get the value of a Symbol variable

                           

                          where is a syntax error here?

                          • 10. Re: How to replay animation interactively
                            AMULI Level 4

                            Sorry Agapyla, and sorry Stéphane. I beg your pardon. I've made the false hypothesis that Stéphane and Agapyla were two avatars of the same people

                             

                            Let's see if Gil translate produces more understandable content :

                             

                            You clicked once on the snippet insertion button Set a variable (in green).

                             

                            Then myVariableName (the placeholder for the first parameter of setVariable) being highlighted, you clicked on the snippet insertion button Get a variable (in blue).

                             

                            //set the value of a Symbol variable

                            sym.setVariable("//get the value of a Symbol variable

                            var myVariable = sym.getVariable("myVariableName");

                            ", "variableValue");

                             

                            Everything after // and till the next carriage return is eliminated. So your code looks for a variable named (string between quotes) var myVariable = sym.getVariable(, which is not an allowed identifier (because of spaces, equal, dot and parenthesis characters).

                             

                            And after that string, the parser expects a comma, which separates from the second parameter of setVariable : the value to assign to the  variable.

                             

                            You do have a syntax error

                             

                            Gil

                            • 11. Re: How to replay animation interactively
                              Agapyla Level 1

                              come on why just not show me the corrected code?

                              I understand this explanation more or less, but what exactly should i do? If var myVariable = sym.getVariable(  is not an allowed identifier so how it should look right?

                              by the way it is 11th stroke of code and Edge points at 10th stroke containing an error.. (unexpected token illegal)

                              • 12. Re: How to replay animation interactively
                                AMULI Level 4

                                come on why just not show me the corrected code?

                                 

                                Because I can't guess what you're trying to do In fact, that's exactly the same with the parser : it can't guess what you have in your mind until you formulate it.

                                 

                                So I did little more than the parser : show you where the error is (and indeed, it was your question).

                                 

                                The difference between the parser and I is that I can understand plain english (I try to). But to get your answer, you can't do without formulating a question, and giving the necessary elements

                                 

                                Gil

                                • 13. Re: How to replay animation interactively
                                  Agapyla Level 1

                                  ok let' start from the beginning)

                                  I make animation in Adobe Edge and put it into Indesign for further work

                                  I use same technique as described above (sym.getSymbol( <yourAnimation>).play(0);)

                                  for several animations in children book

                                  In 6th animation suddenly I have this error   (unexpected token illegal) - in 10th row of code as parser says

                                   

                                  my question is - what is the error and how to fix?

                                   

                                  that is a full part of code:

                                   

                                  var onoff = true;

                                  if (onoff){

                                  // play action

                                  onoff=false;

                                  }else

                                  {

                                  // stop action

                                  onoff=true;

                                  }//set the value of a Symbol variable

                                  sym.setVariable("//get the value of a Symbol variable

                                  var myVariable = sym.getVariable("myVariableName");

                                  ", "variableValue");

                                   

                                   


                                  • 14. Re: How to replay animation interactively
                                    AMULI Level 4

                                    As I explained, you nested two code snippets (including the generated comments) in a manner which has no meaning.

                                     

                                    After inserting a code snippet, you must replace the placeholders (myVariableName, variableValue) with names and values that make sense in your program.

                                     

                                    To give you the correct syntax of the needed statement, at least I need you to express it in plain english.

                                     

                                    Gil

                                    • 15. Re: How to replay animation interactively
                                      resdesign Adobe Community Professional & MVP

                                      Here is an example on how to set an on/off button your action can be anything you want it to be. It is a click event on a button.

                                       

                                      sym.setVariable("onOff", true);

                                      // click event

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

                                                // get the variable

                                                var onOff = sym.getVariable("onOff");

                                                if (onOff == true) {

                                              //your action here.

                                                               // reset the variable to false for next click

                                                               sym.setVariable("onOff", false);

                                                }

                                                else {

                                         // your other action here.

                                                          // reset the variable to false for next click

                                                          sym.setVariable("onOff", true);

                                                }

                                      });

                                      1 person found this helpful
                                      • 16. Re: How to replay animation interactively
                                        Agapyla Level 1

                                        actually i compared code of this edge file with other one (other animation), working without problems and found out all part of code with the error I put above in thread is just some additional part, and I don't find code like this in another animations.

                                        So.. I just deleted this.

                                        After this the animation works in Indesign with some troubles but it is DPS troubles I think, not Edge