10 Replies Latest reply on Apr 15, 2013 1:04 PM by resdesign

    create child and position it

    oliverS

      Hello everybody,

       

      I know it´s simple but It does not work and I cant find it in the forum.

       

      I want to place a symbol on the stage and position it:

       

      sym.createChildSymbol("home", "Stage");

       

      so far so good, but now the "positioning part" (this works fine when I had the symbol allready on the stage):

       

      sym.getSymbol("home").getSymbolElement().css({"position":"absolute","left":  "500px","top":  "500px"});

       

      so I tried different opportunities:

       

      sym.createChildSymbol("home", "Stage").css({"position":"absolute","left":  "500px","top":  "500px"});

       

      sym.createChildSymbol("home".css({"position":"absolute","left":  "500px","top":  "500px"}), "Stage");

       

      But it does not work.

       

      Is there anyone who could help.

       

      THX in advance

        • 1. Re: create child and position it
          resdesign Adobe Community Professional & MVP

          Try this:

           

          var home = sym.createChildSymbol("home", "Stage");

          home.getSymbolElement().css({

                    'position': 'absolute',

                    'left': 50,

                    'top': 50

          });

          • 2. Re: create child and position it
            oliverS Level 1

            Thank you verry much, it was verry helpful.

             

            I recognized that you do a great job in this forum,

             

            so THX.

             

            But there is one more thing...

             

            What, if I want to delete it or maybe replaced the symbol with another symbol,

             

            from a button inside the "home" symbol.

             

            I tryed also different things, with no success.

             

            sym.getSymbol("home").deleteSymbol();  //does not work

             

            var homedelete = sym.getSymbol("home").deleteSymbol();

            sym.getVariable ( homedelete )  //does not work

             

            sym.deleteSymbol(); //this works but it deletes a nested symbol in the "home" symbol but not the home symbol itself

             

             

            or is it the complete wrong way?

             

            But again, thank you verry much for your reply

            and greetings from germany

             

            Oliver

            • 3. Re: create child and position it
              resdesign Adobe Community Professional & MVP

              on the button click event use:

              sym.getComposition().getStage();

              sym.deleteSymbol();

              • 4. Re: create child and position it
                oliverS Level 1

                For some reason it just delete the symbol inside "home" but not the "home" symbol.

                 

                I double click the home symbol in the library and put the code on

                 

                a button wich should erase the "home" symbol from the stage.

                 

                But no luck...

                 

                For better understanding I made a simple edge file:

                 

                https://www.dropbox.com/s/aaknvjzo2acu60r/example.zip

                 

                thank you

                • 5. Re: create child and position it
                  resdesign Adobe Community Professional & MVP

                  If you want to delete the home symbol and all its content, instead of the rectangle inside the button, place the code in the click event of Btn_in_the_home_symbol:

                  sym.getComposition().getStage();

                  sym.deleteSymbol();

                   

                  Here is the updated file. I hope this is what you wanted.

                  https://www.box.com/s/nr3qh6jqi0bj996am1zs

                  • 6. Re: create child and position it
                    oliverS Level 1

                    Oh I am sorry,

                     

                    I need to put the code on the rectangle, cause in my real project

                     

                    the rectangle is a button in the nested complex symbol "Btn_in_the_home_symbol".

                     

                    So, if I undersood it wright, there is now way to delete a symbol on the main stage

                     

                    from within a nested symbol with a nested button.

                     

                    var home = sym.createChildSymbol("home", "Stage");

                    home > Symbol_in_the_home_symbo > rectangle_Button (from here:)

                     

                    sym.getComposition().getStage();

                    sym.deleteSymbol();

                    1 person found this helpful
                    • 7. Re: create child and position it
                      resdesign Adobe Community Professional & MVP

                      Guttentag.

                       

                      What you need to do is look at the API which you can get from help. This is just a matter of targetting elements properly.

                      What you have to think is: What is your rectangle?

                      Symbol Stage contains Symbol Home  which contains symbol Button which contains rectangle and text. So rectangle is a child of button which is a child of Home which is a child of Stage.

                       

                      I am very busy today but I will try to get to your sample tonight unless someone gets to it before or you find the solution yourself.

                       

                      By the way, I lived in Stuttgart for 3 years and loved it.

                      • 8. Re: create child and position it
                        resdesign Adobe Community Professional & MVP

                        Try this in the click event of the rectangle.

                        sym.getComposition().getStage();

                        sym.getParentSymbol().deleteSymbol();

                        1 person found this helpful
                        • 9. Re: create child and position it
                          oliverS Level 1

                          Exelent and exelent explained.

                           

                          But by the way;

                           

                          Dann können wir uns ja wunderbar auf deutsch unterhalten

                           

                          I came from Cologne this is as you mention more north.

                           

                          But compared to America, this is certainly a short distance.

                           

                          So thanks again till neyt time.

                          1 person found this helpful
                          • 10. Re: create child and position it
                            resdesign Adobe Community Professional & MVP

                            Glad to help. Good luck on your project.