5 Replies Latest reply on Nov 7, 2012 12:08 PM by TimJaramillo

    pass symbol instance name to variable

    David M.

      Hi all,

       

      I'm trying to figure out how to pass the instance name (ID) of a clicked object to a variable so I can navigate to a label on the timeline with the same name.

       

      So far I've tried different variations of:

       

      sym.getSymbol() //logs as "undefined"

      sym.getSymbolTypeName // logs the symbol name in the library, not the instance

       

      Any ideas?

       

      Thanks

      -Dave

        • 1. Re: pass symbol instance name to variable
          TimJaramillo Level 4

          Hi David, see below. Here you manually pass in the btnId. Not sure if you're specifically trying to dynamically get the button's instance name?

           

          // code on Stage.compositionReady event

          sym.onClick = function(btnId){

               sym.play(btnID);

          }

           

          // code on your button's click event

          sym.getComposition().getStage().onClick("myBtn");

          • 2. Re: pass symbol instance name to variable
            David M. Level 1

            Hi Tim,

             

            Thanks for the quick response. However, I am trying to dynamically get the button's name. Ideally instead of adding a line of code to each button, I was hoping to add the code to the symbol in the library, that would then pass the instance name of each copy I made.

             

            Right now I have five buttons on the stage with indivdual instance names (nav_btn1 thru nav_btn5). Instead of handcoding an onclick even handler for each button I'd like to dynamically retrieve the instance name of the button clicked and pass it into a variable. In Flash I could do this with  e.target.name ... is there an equivelent in EA and jQuery?

             

            Thanks,

            David

            • 3. Re: pass symbol instance name to variable
              TimJaramillo Level 4

              Hi David,

               

              You can use "e.target.id" on your button click event to get the button's div id.

               

              alert(e.target.id);

               

              The only weird thing is that it seems to prepend "Stage_" to the value, so if your button div is called "myButton", the above will alert "Stage_myButton".

              • 4. Re: pass symbol instance name to variable
                David M. Level 1

                Sweet!

                 

                That worked - Thanks! I ended up combining both your suggestions. on the button symbol i have

                 

                sym.getComposition().getStage().onClick(e.target.id);

                 

                and then after compositionReady I added a function to split out the second name and logged it to test;

                 

                sym.onClick = function(targetId){

                          var names = targetId.split("_");

                          console.log(names[1]);

                }

                 

                Works perfectly! - Although it would be nice if the EA team could fix that functionality in future releases so e.target.id gives you just the id for the selected symbol. I would think if you can write something like getSymbol("mySymbol") it should be just as easy to get that name without all the extra (Stage...etc)

                 

                Thanks again!

                -David

                • 5. Re: pass symbol instance name to variable
                  TimJaramillo Level 4

                  No problem!

                   

                  Agreed, the "Stage_" prepending deal is weird. Maybe I'm missing something in the documenation for a more direct way to grab the clicked button id. I don't see anything in the API doc though: http://www.adobe.com/devnet-docs/edgeanimate/api/current/index.html