2 Replies Latest reply on Nov 20, 2012 9:22 AM by Coreydwillis

    Removing ChildSymbol Instances

    Coreydwillis Level 1

      Basically what I'm doing is changing my "page" variable when a navigation button is pressed. If the "Demo" button is pushed, then "page=demo" for example.


      Demo Button Code

      page = "demo";



      After this variable is set, I call the changePage function from that button and it executes this code:


      The Function Code

      window.changePage=function() {

                if (page != "demo") {

                          var pageDisplay =sym.createChildSymbol(page,'Stage');

                          pageDisplay.getSymbolElement().css({"left": "8px", "top": "62px"});


                else {

                          var pageDisplay =sym.createChildSymbol(page+lesson,'Stage');

                          pageDisplay.getSymbolElement().css({"left": "8px", "top": "62px"});




      What I'm doing is saying that it will load a symbol that matches the current state of the "page" variable. The problems is that once the function is called again, it places the next symbol below it. I want it to remove the first instance of "pageDisplay", then create the new instance based on whatever the variable value is right then. I tried different delete functions, but they kept just completely breaking it the function.

        • 1. Re: Removing ChildSymbol Instances



          Not sure if it's the optimal way, but this is the way i delete the created items... (Maybe someone can optimize this)...

          when adding the object, add




          And then get the childsymbols from where you created them:


          var onLocationChildSymbols = sym.getComposition().getStage().getChildSymbols();


                                                                     if (this.getVariable("type")=="createdButton"){




          • 2. Re: Removing ChildSymbol Instances
            Coreydwillis Level 1

            Thanks! That totally worked! :-D