11 Replies Latest reply on Nov 2, 2014 7:44 AM by randy@technologyskills

    Delete child symbol from stage

    randy@technologyskills Level 1

      Hi All,

       

      I need help deleting a symbol from the stage.  I have a list of symbols that are called to the stage at some point in a simulation. When the user leaves one symbol, it is supposed to delete itself and call up another (specific) symol.  For example.  I called the symbol “AR-HistAims” to the stage using

       

      var mySymbolObject = sym.createChildSymbol("AR-HistAims", "Stage");

                  mySymbolObject.getSymbolElement().css({'position':'absolute','left': (mouseX - offset.left)/sx , 'top': (mouseY - offset.top)/sy});

                  mySymbolObject.play();

       

      This works fine.  I place an invisible button in the symbols timeline and when it is clicked I want it to do two things. 

       

      1. call up “AR-percPass” (using the same code as above with a percPass in place of HistAims)
      2. remove “AR-HistAims” from the stage. 

       

      I can’t seem to get #2 to work.  I’ve tried codes below and above the code for #1.  When placed above, it deletes the current symbol, but doesn’t call up the new one.  When placed below, the new symbol appears on top of the old one.  The codes I've used are:

       

                  var childSymbols=sym.getComposition().getSymbols("AR-HistAims");

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

                  childSymbols[i].deleteSymbol();

      //and

                  var mySymbolObject = sym.getParentSymbol().getSymbol("mySymbol").getVariable("AR-HistAims");

                  stage.deleteSymbol();

      //and

      1. sym.getParentSymbol().deleteSymbol();

       

      Any advice would be appreciated.

       

      Thanks

      Randy

        • 1. Re: Delete child symbol from stage
          vivekuma Adobe Employee

          Can you share your composition for us to take a closer look?

           

          Regards,

          Vivekuma

          • 2. Re: Delete child symbol from stage
            randy@technologyskills Level 1

            Hi Vivekuma,

             

            Sure.  I've removed a bunch of images to reduce file size, but everything someone would need to troubleshoot is there.  I left a message on the main stage on how to get to the error as well.

             

            Thanks

            Randy

             

            Dropbox - AZDash self guided tour.zip

            • 3. Re: Delete child symbol from stage
              vivekuma Adobe Employee

              Hi Randy,

               

              There are a few corrections you need to make in index_edgeAction.js file like as follows:

              1. In click handler, you don't have access to  mouseX, offset, sx, sy etc.

                   mySymbolObject.getSymbolElement().css({'position':'absolute','left': (mouseX - offset.left)/sx , 'top': (mouseY - offset.top)/sy});

                   So, make it like this:

                   mySymbolObject.getSymbolElement().css({'position':'absolute','left': 0 , 'top': 0});

                   Make these kind of changes for every click handler where you have used mouseX, offset, sx, sy etc, with appropriate left and top values.

              2. Just search for sym.getSymbolElement().deleteSymbol(); and replace it with sym.deleteSymbol();

              3. Comment out line#1366  having statement sym.deleteSymbol ();

              4. Search for sym.getSymbol(home).deleteSymbol(); and replace all such occurences with sym.getSymbol("home").deleteSymbol();

               

              With the above changes, things will work.

               

              hth,

              Vivekuma

              • 4. Re: Delete child symbol from stage
                randy@technologyskills Level 1

                Hi Vivekuma,

                 

                Thank you so much for looking at my project.  I had tried both of the solutions you mentioned (deleteSymbol and position) before submitting here and neither worked for me, but when I copied from your code and pasted into mine it worked just fine.  I must have had some typos I couldn't see. 

                 

                Thanks again,

                Randy

                • 5. Re: Delete child symbol from stage
                  randy@technologyskills Level 1

                  Hi Vivekuma,

                   

                  Sorry to bother you with this again, but I was wrong about sym.deleteSymbol(); working.  When I use follow the code

                   

                  var mySymbolObject = sym.createChildSymbol("AR-percPass", "Stage");

                    mySymbolObject.getSymbolElement().css({'position':'absolute','left': 0 , 'top': 0});

                    mySymbolObject.play();

                   

                  sym.deleteSymbol.();

                   

                  I don't end up where I'm supposed to be, but it looks like the correct symbol was deleted.  When I comment out sym.deleteSymbol(); nothing gets deleted, but the proper symbol is displayed on the stage.

                   

                  Any thoughts?

                   

                  Thanks

                  Randy

                  • 6. Re: Delete child symbol from stage
                    vivekuma Adobe Employee

                    Which line number (having code: sym.deleteSymbol.();) did you comment out?

                    • 7. Re: Delete child symbol from stage
                      randy@technologyskills Level 1

                      Line 1371.  I tried a couple of different variations as well.  One at a time, and commented them out as well.  You can see the  on lines 1370-1377.  Before, I showed you a smaller file with many images removed to reduce file size.  Here's the full thing.

                       

                       

                      Dropbox - AZDash self guided tour.zip

                      • 8. Re: Delete child symbol from stage
                        vivekuma Adobe Employee

                        But If you don't comment line#1371, then after clicking "Historical AIMS", you'll get back to the state that comes after you first click the "AZ Dash" on the landing page.

                        That's why I commented it out.

                        • 9. Re: Delete child symbol from stage
                          randy@technologyskills Level 1

                          Then aren't I left with my original issue?  The goal with that is to delete the existing symbol (ArHomeScreen in this case) and then display the new one (AR-HistAims) when I click the button.  How then, do I delete ArHomeScreen?

                          • 10. Re: Delete child symbol from stage
                            vivekuma Adobe Employee

                            It's getting very confusing the way you are referring the different symbol name. It will be better to share a composition the way you have shared in the beginning with the hints on what to click and what is the expected behaviour.

                             

                            And in the lines between 1370-1377, if you add statement like

                                     console.log("Symbol Object: ", sym.getSymbol("ArHomeScreen"));

                            this will get "Symbol Object: undefined", when you click "Historical AIMS", that undefined means there is no such symbol with name "ArHomeScreen".

                             

                            so it seems like there is implementation issue with the way you are creating and deleting a symbol. It's very difficult to go through the whole code and understand what you intend to do with various symbols, unless you send a composition with hints on stage.

                             

                            Regards,

                            Vivekuma

                            • 11. Re: Delete child symbol from stage
                              randy@technologyskills Level 1

                              ok, let me take a different approach.  In the original composition, I called all of the symbols to the stage (except the popups) and symbols would hid/show according to what was clicked.  The problem was that it takes up to 15 seconds to load when I'm testing it online.  So I removed all of the symbols from the stage and only called them as needed, to reduce load time.  That's when my problems started.  So I'm guessing that I'm not calling the symbols up correctly.  I've spent some time looking around for the best way to call and remove symbols in my situation, but I think I'm lost.