5 Replies Latest reply on Dec 5, 2013 6:21 AM by resdesign

    Deleting multiple symbols

    NYG-vibeke

      I'd like to delete all symbol instances on a click event, the

       

      sym.getSymbol("SymbolDefinitionName").deleteSymbol();


      only works on one symbol, and I've tried combining it with both

       

      sym.getComposition().getSymbols("SymbolDefinitionName");


      and

       

      sym.getSymbolElement().children();

       

      any ideas on how to do this would be much appreciated!

       

       


        • 1. Re: Deleting multiple symbols
          resdesign Adobe Community Professional & MVP

          You could assign a class to your symbols and then delete all of them like this on your click event. (do not forget the dot for the class name.

           

          sym.$('.classname').deleteSymbol();

          • 2. Re: Deleting multiple symbols
            NYG-vibeke Level 1

            thanks, that's a good idea. However, I don't know how to add a class to a dynamic symbol instance - can I use jQuery's .addClass() method? I've tried, but I can't seem to make it work:

             

            sym.creator = function(){

            var g = sym.createCholdSymbol('tester', 'Stage');

            g.$('txt').html('hello');

            g.addClass('fnames'); //this doesn't work

            };

             

            sym.destroyer = function(){

            sym.$('.fnames').deleteSymbol();

            }

            • 3. Re: Deleting multiple symbols
              michaelAkl

                var childSymbols = sym.getComposition().getSymbols("SymbolDefinitionName");

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

                                                                                                   childSymbols[i].deleteSymbol();

               

              Cheers!

              • 4. Re: Deleting multiple symbols
                NYG-vibeke Level 1

                Perfect, Michael!

                • 5. Re: Deleting multiple symbols
                  resdesign Adobe Community Professional & MVP

                  Example below:

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

                  // add class to a created symbol

                  NewSymbolInstance.element.addClass("aClassName");

                  // add ID to a created symbol

                  NewSymbolInstance.element.attr("id","idnew");

                  // do not forget the # tag.

                  sym.getSymbol("#idnew").$("Text").html("XXXXXXX");

                  sym.getSymbol("#idnew").$("Ellipse").css({'background':'green'});

                  sym.getSymbol("#idnew").$("Rectangle").html("Rectangle");

                  sym.getSymbol("#idnew").$("Rectangle").addClass("aClassName");

                  sym.getSymbol("#idnew").$("Ellipse").addClass("aClassName");

                  sym.getSymbol("#idnew").$("Text").addClass("aClassName");

                  sym.$('.aClassName').css({'left':100});

                  sym.$('.aClassName').deleteSymbol();

                   

                   

                  But Michael's for loop is fine too. I just like working with classes when possible.