11 Replies Latest reply on May 2, 2013 11:10 AM by resdesign

    Can't Remove Dynamically Created Symbol Instance

    Alpinist74

      Hi all,

       

      I have a symbol instance called from the library using this trigger:

       

      var stopAll = sym.getComposition().getStage().getSymbol("comb").getChildSymbols();

      for(var i=0; i<stopAll.length; i++) // Return the number of direct children

      stopAll[i].stop();// Create an instance element of a symbol as a child of the

      var chromo1 = $(sym.createChildSymbol("Peak1_1", "Stage").getSymbolElement());

      chromo1.css({marginLeft:175, marginTop: 500});

       

      This correctly stops all symbols within a main symbol from playing and positions the symbol instance "Peak1_1" on stage.

       

       

      Then, within the symbol that was instantiated ("Peak1_1") I have a button symbol "CloseChromo1" with the following actions

       

      var startAll = sym.getComposition().getStage().getSymbol("comb").getChildSymbols();

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

      startAll[i].play();

      sym.getComposition().getStage().sym.$("Peak1_1").remove();

       

      The first three lines work and effectively restart the stopped child symbols.

       

      The fourth line, which should remove the instantiated symbol from stage doesn't work. I have tried referencing the instance name ("chromo1"), and hiding it using the GetSymbolElement, which doesn't work. I have tried using deleteSymbol() and referencing the entire symbol tree, starting from the Composition level, and this doesn't work. I have tried all possible variations I can think of, including referencing through children and parents -- still no joy.

       

      What am I doing wrong?

       

      Thanks in advance for any help!

       

      Matt