5 Replies Latest reply on Jan 14, 2014 11:06 AM by elainecc

    Cannot delete dynamically created symbols.

    jpringles Level 1

      I have a dynamically created symbol going into a parent div. not the Stage.

       

      using:

      var water = sym.createChildSymbol("water", "water_pos", 0);

      var fishing = sym.createChildSymbol("fishing_boat", "fishing_boat_pos", 1);

       

      I need 4 animated scenes but only showing one at a time. It was runnng slowly if left running for a while (which is also strange) so I'm trying to only load what I need.

       

      The symbols are creating perfectly but for some reason I cannot delete them whan i'm finished with them.

       

      I can delete the other symbols that were not dynamically created in the project but cannot single out the new instances of symbols and delete them.

      I am using the deleteSymbol() API.

       

      I have tried the correct answer here but it is deleteing my whole screen leaving a white BG??

      They suggest:

      You use pass the symbol to be deleted in as the parameter for the deleteSymbol() method, like so:

       

      sym.deleteSymbol("Peak1_1");

      http://forums.adobe.com/message/5283417#5283417

       

      I'm Bamboozled!

       

      What am I missing!

       

      Thanks for any help or suggestions.

       

      Johnny

        • 1. Re: Cannot delete dynamically created symbols.
          elainecc Adobe Employee

          Try:

           

          water.deleteSymbol();

          fishing.deleteSymbol();

           

          -Elaine

          • 2. Re: Cannot delete dynamically created symbols.
            jpringles Level 1

            Thank for the suggestion Elaine.

             

            I tried that code on a button when clicked but it didn't work.

            I also tried it on a trigger and it didn't work.

            Nothing happens at all.

             

            You said on a different thread I need to "maintain a reference to the symbols after you create them" so I can delete them.

             

            How would I do that? How do I hard code the name of the symbol as suggested in the link below?

            http://forums.adobe.com/message/5328248#5328248#5328248

            My symbols are not nested symbols. They are on the stage and being called to a div on the stage when created.

            • 3. Re: Cannot delete dynamically created symbols.
              jpringles Level 1

              HI elaine.

               

              I have also tried your suggestion on another thread (http://forums.adobe.com/thread/1262104) where you are creating a reference to the symbol on creation but still no Luck!!

               

               

              I created a new project just to test this. I have one symbol called "sym" and one div called "pos" that i'm creating the symbol in.

               

              Create:

              var test = sym.createChildSymbol("sym", "pos");

              sym.setVariable("var1", "test"); ..................................(your example didn't have inverted commas on "test". sym.setVariable("bar", foo);) no sure which is correct.

               

               

              Delete:

              var test = sym.getParentSymbol().getSymbol("sym").getVariable("var1");

              test.deleteSymbol();

               

              I tried instead of getting the parentSymbol:

              var test = sym.getComposition().getStage().getSymbol("sym").getVariable("var1");

              test.deleteSymbol();

               

              and:

               

              var test = sym.getSymbol("sym").getVariable("var1");

              test.deleteSymbol();

               

               

              Still no luck!

              • 4. Re: Cannot delete dynamically created symbols.
                jpringles Level 1

                I found the solution from timjamarillo over on this thread: http://forums.adobe.com/message/4848076

                 

                I took me a while to find it so i'll put it here in case anyone else needs it!!

                 

                .....

                 

                It's probably a scope issue. I recommend putting all functional code on Stage.compositionReady event, then calling those functions from wherever you need them.

                 

                Put this code on Stage.compositionReady:

                 

                // store your symbol

                sym.mySymbol;

                 

                sym.createParticle = function(){

                             // pull symbol from library, add to Stage

                             sym.mySymbol = sym.createChildSymbol("Food_Spanner", "Stage");

                }

                 

                sym.removeParticle = function(){

                     // delete symbol

                     sym.mySymbol.deleteSymbol();

                }

                 

                Put this code on frame 1:

                sym.getComposition().getStage().createParticle();

                 

                 

                Put this code on frame 15:

                sym.getComposition().getStage().removeParticle();

                • 5. Re: Cannot delete dynamically created symbols.
                  elainecc Adobe Employee

                  Glad you worked it out!

                   

                  -Elaine