12 Replies Latest reply on Nov 21, 2012 10:55 AM by AmintaAdobe

    Can't delete all elements on stage and "clear a scene"

    AmintaAdobe Level 1

      Hi folks!

       

       

      I've got a problem using the deleteSymbol() Api function. It works only for the... symbols, but not for the element.

       

      In this online example, the moving gray rectangle is a symbol and the "some text" is a text-element Div: http://www.terredainventare.it/delete/MyDeleteSymbols.html

       

      Here are the project files: http://www.terredainventare.it/delete/DeleteSymbols.zip

       

       

      If you click "Cleare etc" only the Symbol disappears.

       

      Here's the code I've tried at the event "click":

       

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

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

      sym.$("Text").remove();

       

       

      One more question: what if I want delete all the elements that are now on the stage (symbols + elements)?

       

      I've tried:

       

      sym.getComposition().getStage().getChildSymbols().deleteSymbol();

       

      but it doesn't work.

       

       

      And, if I can "Clear the scene" to go to another "scene" in where I put some other animations and text, how can I do that? How can pratically create a new "scene"?

       

       

      Many thanks in advance for your precious help!

       

       

      Davide

        • 1. Re: Can't delete all elements on stage and "clear a scene"
          joel_pau Level 5

          Hello Davide,

           

          1) This code will work on your Clear.click:

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

          sym.$("Text").remove();

           

          Note: Line #2 [sym.getSymbol("Text").deleteSymbol("Text");] prevented line #3 [sym.$("Text").remove()] to run.

           

          2) Now, if you want to clear your scene:

          sym.$("Stage").children().remove();

           

          I checked both codes [ 1) & 2) ] using your file.

          • 2. Re: Can't delete all elements on stage and "clear a scene"
            AmintaAdobe Level 1

            THANKS JOEL!

             

            Your answer was so prompt and useful!

             

            Can I take advantage of your skill to ask you how - when I remove some of all elements - can I make them appear again?

             

            Thanks!

             

            Davide

            • 3. Re: Can't delete all elements on stage and "clear a scene"
              joel_pau Level 5

              1) So, you can hide stage children then show them.

              2) On stage, you have only symbols.

              You create or recreate an instance symbol (a child from your symbol library) writing:

              var mySymbolObject = sym.createChildSymbol("Symbol_1", "Stage");

              Then you delete using deleteSymbol() function. You also have beforeDeletion to manage your composition.

               

              Yesterday, i forgot beforeDeletion [Edge API] and .empty() [jQuery].

              EA 1.0 provide a tool: beforeDeletion. You can use it. Here an use with your post #1: file attached.

              Here is another file about deleting symbols. 2 case: inside (close button) or outside (delete button) a symbol: file attached.

              1 person found this helpful
              • 4. Re: Can't delete all elements on stage and "clear a scene"
                AmintaAdobe Level 1

                THANKS JOEL!

                 

                Your explanation was very USEFUL for me! You should write a manual for the Edge Apis!!

                 

                 

                So, I studied carefuly your examples, and I have three more (and LAST! :-)   ) questions for your kind attention!

                 

                1) in wich cases is worthwhile to use the "beforeDeletion" Api? Is it usfeul only to remove elements toghether with the symbols?

                 

                2) with "    sym.createChildSymbol("details", "Stage");   " you can also nest a symbol inside a symbol (called for example symbol 2), in this way? -> sym.createChildSymbol("details", "symbol 2");

                 

                3) in "MyDeleteSymbols" example, with "clear" you remove all symbols and elements off the stage. Ok. But what if I want recreate all them in the SAME POSITION as before?

                 

                 

                Many many thanks for your essential help!!

                 

                Davide

                • 5. Re: Can't delete all elements on stage and "clear a scene"
                  AmintaAdobe Level 1

                  Sorry Joel.... one more thing: ;-)

                   

                  What if I want create transitions-effects (like slide-effect) to go from a symbol-scene-stage to another symbol-scene-stage of the same size?

                   

                  Still many thanks!

                   

                  Davide

                  • 6. Re: Can't delete all elements on stage and "clear a scene"
                    joel_pau Level 5

                    AmintaAdobe wrote:

                     

                    THANKS JOEL!

                     

                    Your explanation was very USEFUL for me! You should write a manual for the Edge Apis!!

                     

                     

                    So, I studied carefuly your examples, and I have three more (and LAST! :-)   ) questions for your kind attention!

                     

                    1) in wich cases is worthwhile to use the "beforeDeletion" Api? Is it usfeul only to remove elements toghether with the symbols?

                     

                    2) with "    sym.createChildSymbol("details", "Stage");   " you can also nest a symbol inside a symbol (called for example symbol 2), in this way? -> sym.createChildSymbol("details", "symbol 2");

                     

                    3) in "MyDeleteSymbols" example, with "clear" you remove all symbols and elements off the stage. Ok. But what if I want recreate all them in the SAME POSITION as before?

                     

                     

                    Many many thanks for your essential help!!

                     

                    Davide

                    About 1): You can preserve datas if your symbol is a form, you can add a closure animation, you can launch another symbol, etc.

                    About 2): You can use a symbol as a container: sym.createChildSymbol("details", "container"); See sample files (twitter) here.

                    About 3): You can easily create and recreate symbols. You write a function. Other elements can be hidden rather than deleted.

                    Here is a file attached (v3). Can be improved using: a function, setVariable and getVariable. New file attached (v4).

                    • 7. Re: Can't delete all elements on stage and "clear a scene"
                      AmintaAdobe Level 1

                      Once again THANKS JOEL!

                       

                      Now, thanks to your function, I've learned how to re-create a symbol in the same position where it was deleted.

                       

                      But I have a (very last) question: what if I want to delete a Symbol that is already on the stage and then recreate it in the same position?

                       

                      I've tried to nest a toggle function in a click function, but it doesn't work. Can you take a look? www.terredainventare.it/SymbolsOnStage.zip

                       

                       

                      THANKS!

                       

                      Davide

                      • 8. Re: Can't delete all elements on stage and "clear a scene"
                        joel_pau Level 5

                        Do you want this? File attached.

                        I added 2 files (v2 and v3).

                        • 9. Re: Can't delete all elements on stage and "clear a scene"
                          AmintaAdobe Level 1

                          Hi Joel, thanks for the last files, but I wonder if I can delete a symbol that is already drawn on the stage, like my first example!

                           

                           

                          Thanks!

                           

                          Davide

                          • 10. Re: Can't delete all elements on stage and "clear a scene"
                            AmintaAdobe Level 1

                            Hi Joel!

                             


                            Sorry to bother you again, but I've encountered an unexepected behaviour when I try to hide a symbol after I've created it with a function:

                             

                            (Stage, CompositionReady):

                             

                            sym.CreateSymbol = function (symbolName,x,y){

                            sym.symbolName = symbolName;

                            sym.symbolName = sym.createChildSymbol(symbolName, "Stage");

                            sym.symbolName.getSymbolElement().css({"left":x, "top":y});

                            };

                                 

                            sym.onClickMake = function ()

                            {

                            sym.a = sym.CreateSymbol ("Elli", "0px", "10px");

                            sym.a.getSymbolElement().hide;

                               

                            }

                             

                            In the console I get this error: "Javascript error in event handler! Event Type = element".

                             

                            Here is the project file: http://www.terredainventare.it/CreateDeleteSymbolfunction.zip

                             

                            Many thanks!!

                             

                            Davide

                            • 12. Re: Can't delete all elements on stage and "clear a scene"
                              AmintaAdobe Level 1

                              THANKS Joel!

                               

                              So, I explain these two lines of code:

                               

                              sym.CreateSymbol ("Elli", "40px", "60px");

                              sym.symbolName.getSymbolElement().hide(3000);

                               

                               

                              in the meaning that, given that you use in "sym.CreateSymbol" function the arguments "symbolName, x, y", the istance created with this function assumes always the name of "symbolName". Is it correct?

                               

                              But why I can't assign this istance to a variable and hide the variable, like this?

                               

                              var a = sym.CreateSymbol ("Elli", "40px", "60px");

                              sym.a.getSymbolElement().hide(3000);

                               

                              (I get always "Javascript error in event handler! Event Type = element" in the console.log)

                               

                              STILL MANY THANKS!


                              Davide