11 Replies Latest reply on Jan 11, 2013 4:48 PM by jbowden

    What's wrong with my sintax?

    pmfr01 Level 2

      The code:


      var arraySections = ["section_Btn_nosContigo", "section_Btn_nosSomos", "section_Btn_nosAoVivo", "section_Btn_nosTemos", "section_Btn_nosVivemos"];
      var sectionActive = sym.getPosition(arraySections);
      if (sectionActive > 2499) {


      I think it's self-explanatory, but it doesn't work...

        • 1. Re: What's wrong with my sintax?
          heathrowe Most Valuable Participant

          Is the arraySection a collection of Labels from the timeline?



          • 2. Re: What's wrong with my sintax?
            pmfr01 Level 2

            Nope. They're symbols.

            • 3. Re: What's wrong with my sintax?
              heathrowe Most Valuable Participant

              Its hard to determine the goal, not knowing what your references alude to and where they exist within the project.


              Can you provide more details along with zipped project files.



              • 4. Re: What's wrong with my sintax?
                pmfr01 Level 2

                The idea is to play only the symbol who's timeline is currently at > 2499.

                Sorry for not providing the original files - it's a big project with a bunch of symbols - it would be confusing.

                • 5. Re: What's wrong with my sintax?

                  sym.getPosition() takes no arguments according to API. Looks like you need something like this:


                  var arraySections = ["section_Btn_nosContigo", "section_Btn_nosSomos", "section_Btn_nosAoVivo", "section_Btn_nosTemos", "section_Btn_nosVivemos"];
                  arraySections.forEach(function (element) {
                       // search for actual symbol through sym.getComposition().getStage().getSymbol(element) and go deep in case symbols are not on the same level
                       // if (sym.getPosition() > 2499) {
                       //    sym.playReverse("mouseout");
                       //  } 


                  Code is not exact since many details are missing but I hope this will give you a direction.
                  • 6. Re: What's wrong with my sintax?
                    pmfr01 Level 2

                    Hmm...I think I may be putting things wrongly.

                    Let me try and explain better what I need:


                    - 5 buttons (symbols) » 5 webpages (with fade in/out animations);


                    For ex. I click button_1 and it opens it's correspondant webpage - webpage_1;

                      - When webpage_1 loads, it plays the label 'section_enter' animation inside button_1, rendering it unclickable;

                      - If I click button_2, it plays the current's page (webpage_1) fade out animation and the button's (button_1) label 'section_exit' animation and, finally, opening webpage_2.


                    I thought putting the button's symbols in an array would be the right way to do it, but it's provinga bit confusing to me. Besides, I put the code in compositionReady(Stage) and I should probably put it in the click action of all buttons instead...

                    I'm really not sure how to do this...

                    • 7. Re: What's wrong with my sintax?
                      elainecc Adobe Employee

                      I'm going to take a stab at this, even though it's not very clear to me how you're implementing things in the project, which is why Darrell asked you to post the project files - complexity doesn't matter, because we're looking for something very specific and it would take a while to ask you until we get the information we need.  If your array is names of your symbol instances, which I hope they are:


                      arraySections.forEach(function(instance) {

                        var position = sym.getSymbol(instance).getPosition();

                        if (position > 2499) {

                          // here is my code




                      Hope that helps point you in the right direction.



                      • 8. Re: What's wrong with my sintax?
                        pmfr01 Level 2

                        Thanx for the reply.

                        My array is:


                        arraySections = ["section_Btn_nosContigo","section_Btn_nosAoVivo","section_Btn_nosTemos", "section_Btn_nosVivemos"];


                        What do I put in "instance"?

                        • 9. Re: What's wrong with my sintax?
                          eduard.dudar Level 1

                          Okay, from this description it's clearer what you're going to achieve. The code should be in a click handler for each button.



                          When all button are on the same level which is good them you search for them as:

                          var buttons = sym.getParentSymbol().getChildSymbols();



                          Otherwise you'll need to go recursively through your composition:

                          function contains(name, array) {

                             for (var i = 0; i < array.length; i++) {

                                if (array[i] === name) {

                                   return true;



                             return false;



                              function findButtons(symbol, array) {

                                  var children = [];

                                  var childSymbols = symbol.getChildSymbols();

                                  for (var i = 0; i < childSymbols.length; i++) {

                                      if (contains(childSymbol.getSymbolTypeName(), array)) {


                                      } else {

                                          var innerResult = findButtons(childSymbols[i], array);

                                          for (var j = 0; j < innerResult.length; j++) {





                                  return children;



                          var buttons = findButtons(sym.getComposition.getStage(), ["section_Btn_nosContigo", "section_Btn_nosAoVivo", "section_Btn_nosTem os",  "section_Btn_nosVivemos"])



                          And finally you traverse through buttons found and play either section_enter or section_exit

                          buttons.forEach(function(button) {

                                    if (button === sym) {


                                    } else {




                          • 10. Re: What's wrong with my sintax?
                            pmfr01 Level 2

                            eduard.dudar, do I really need so much code? Besides, I don't need a button.play. I only need to search inside an array of symbols, the one symbol that has the timeline at > 2499ms.

                            • 11. Re: What's wrong with my sintax?
                              jbowden Adobe Employee

                              Hi pmfr01,


                              As you've defined it in your code, arraySections is a variable referencing an array of symbols (as I'm sure you know). However, getPosition only gets the playhead position of the default timeline, and returns a number (time in milliseconds). The getPosition method doesn't take an argument, as mentioned previously.


                              So to do what you want, you'll need to iterate through the array, getPosition for each symbol timeline in the array, and then test for if it is > 2499.


                              This link may help with how to work with an array in JavaScript:




                              And this link may help in looping through the array:




                              Finally, the Edge Animate JavaScript API can explain more about what you can do with JavaScript within EA: