9 Replies Latest reply on Jan 9, 2013 10:11 AM by AmintaAdobe

    How to get symbol ID in Edge

    AkariKamigishi Level 1

      I have some codes like this:

       

      function myFunc(name) {

           var $symbol = sym.$(name);

       

           //I want to do something with $symbol depending on their id, for example

           //$item.appendTo($symbol);

           //so $item will append to the corresponding symbol

      }

       

      for (var i=0; i<10; i++) {

           var symbol = sym.createChildSymbol("MySymbol", sym.$(Stage"));

           myFunc(symbol.getSymbolElement().attr('id')); <--not working

      }

       

      I tried .attr('id') and it seems not the id I want. Thanks for help.

       

      EDIT: indeed I want to get the selector inside myFunc

        • 1. Re: How to get symbol ID in Edge
          Aiesyaah Level 1

          Hey..

          I always do this to get the ID. After I run it in the browser, I right click > Inspect Element (on the symbol you want to know the ID), and it will be displayed. Hopefully it works for you.

          • 2. Re: How to get symbol ID in Edge
            AkariKamigishi Level 1

            You method gives the same thing as .attr('id') and it seems the the thing I want. Maybe the thing I want is called selector? Thanks anyway.

            • 3. Re: How to get symbol ID in Edge
              AkariKamigishi Level 1

              I think I figure out the solution:

               

              function myFunc($symbol) {

                   //I want to do something with $symbol depending on their id, for example

                   //$item.appendTo($symbol);

                   //so $item will append to the corresponding symbol

              }

               

              for (var i=0; i<10; i++) {

                   var symbol = sym.createChildSymbol("MySymbol", sym.$(Stage"));

                   myFunc(symbol.getSymbolElement());

              }

              • 4. Re: How to get symbol ID in Edge
                joel_pau Level 5

                How to get symbol id? sym.lookupSelector()

                • Creating a rectangle on Stage, sym.lookupSelector("Rectangle") returns "#Stage_Rectangle".
                • sym.lookupSelector("oneSymbol") returns symbol id.

                 

                Now: for (var i=0; i<10; i++) { var symbol = sym.createChildSymbol("MySymbol", "Stage")); };

                So, ten children have been created.

                • sym.lookupSelector(symbol[0]) returns first child id.
                • sym.lookupSelector(symbol[9]) returns last child id.

                You can write:

                $( sym.lookupSelector(symbol[0]) ).hide();

                or

                $( sym.lookupSelector(symbol[9]) ).css(...)

                1 person found this helpful
                • 5. Re: How to get symbol ID in Edge
                  AmintaAdobe Level 1

                  Hi Joel!

                   

                  Following your very useful hint, I tried to write down this code:

                   

                  var symbol = sym.createChildSymbol("rect", "Stage")

                  var ID = sym.lookupSelector(symbol[0])

                   

                   

                  ID.hide();

                   

                   

                  But it doesn't work.

                   

                  Why?

                   

                  Thanks in advance,


                  Davide

                  • 6. Re: How to get symbol ID in Edge
                    joel_pau Level 5

                    Hello Davide,

                     

                    So i rewrite an effective code be cause i was wrong this morning.

                    joel_pau wrote:

                     

                    How to get symbol id? sym.lookupSelector()

                    • Creating a rectangle on Stage, sym.lookupSelector("Rectangle") returns "#Stage_Rectangle".
                    • sym.lookupSelector("oneSymbol") returns symbol id.

                     

                    Now: for (var i=0; i<10; i++) { var symbol = sym.createChildSymbol("MySymbol", "Stage")); };

                    So, ten children have been created.

                    • sym.lookupSelector(symbol[0]) returns first child id.
                    • sym.lookupSelector(symbol[9]) returns last child id.

                    You can write:

                    $( sym.lookupSelector(symbol[0]) ).hide();

                    or

                    $( sym.lookupSelector(symbol[9]) ).css(...)

                     

                    for (var i=0; i<10; i++) {

                                var mySymbol = sym.createChildSymbol("rect", "Stage");

                                mySymbol.$("Text").html("child #"+i);

                                mySymbol.$("idText").html("rectangle ID = "+mySymbol.lookupSelector("Text"));

                                mySymbol.$("idRectangle").html("text ID = "+mySymbol.lookupSelector("Rectangle"));

                    };

                     

                    var symbolChildren = sym.getChildSymbols();

                    symbolChildren[1].$("Rectangle").css("background-color","red");

                    symbolChildren[2].getSymbolElement().hide(5000);// ==> display:none

                    symbolChildren[5].getSymbolElement().css("visibility","hidden");//place is empty

                     

                    console.log(symbolChildren[3].getSymbolElement().attr('id'));


                     

                    ==> attachments.

                    • 7. Re: How to get symbol ID in Edge
                      AmintaAdobe Level 1

                      Hi Joel!!

                       

                       

                      Sorry for my very late feedback, but I was busy in the last weeks :-(

                       

                       

                      THANKS for your excellent explanation! Can you upload again the example files, because they are expired?

                       

                       

                      Thanks!

                       

                      Davide

                      • 8. Re: How to get symbol ID in Edge
                        joel_pau Level 5

                        ==> attachments

                         

                        post #6 code ==> see folder: "lookupSelector1".

                        • 9. Re: How to get symbol ID in Edge
                          AmintaAdobe Level 1

                          Thanks Joel!!! Your explanation and your files were - as usual - very very useful to learn to work in Edge with code!

                           

                           

                          Thanks!

                           

                          Davide