3 Replies Latest reply on Jan 8, 2013 9:40 AM by TimJaramillo

    Refering nested symbols in array?

    pmfr01

      How do I reference, in an array,  symbols that are nested inside another symbol? Do I have to use variables or something?

        • 1. Re: Refering nested symbols in array?
          TimJaramillo Level 4

          Hey Pedro, in your other thread, the code I gave you has an example of this, but for posterity, see below:

           

          // array

          var array_options = ["option1", "option2", "option3"];

           

          myFunc = function(){

               // get "myParentSymbol", then get this object (index 0 from "array_options"), nested inside "myParentSymbol"

               sym.getSymbol("myParentSymbol").getSymbol(array_options[0] ).play("out");

          }

          • 2. Re: Refering nested symbols in array?
            pmfr01 Level 2

            That's it. Reviewing:

             

            var array_options = ["option1", "option2", "option3"];
            myFunc = function(){
              sym.getSymbol("myParentSymbol").getSymbol(array_options[0] ).play("out");
            }
            myFunc();
            
            var array_options = ["symbol1","symbol2","symbol3"];
            sym.getSymbol("symbols").getSymbol(array_options[0]).play('section_activate');
            

             

            By the way, is it possible to use sym.getPosition(); with an array?

             

            Thanx Tim.

            • 3. Re: Refering nested symbols in array?
              TimJaramillo Level 4

              Indeed, to get the current timeline position of a nested symbol, using an array, you could do this:

               

              // array

              var array_options = ["option1", "option2", "option3"];

               

              myFunc = function(){

                   // get "myParentSymbol", then get this object (index 0 from "array_options"), nested inside "myParentSymbol"

                   sym.getSymbol("myParentSymbol").getSymbol(array_options[0] ).getPosition();

              }