9 Replies Latest reply on Jul 10, 2013 2:19 PM by resdesign

    More syntax questions about nested symbols

    John Hall Level 4

      I have a symbol timeline that does everything I need it to do except to access a function within the stage symbol. I would have thought that calling the function in the stage symbol from a nested symbol (which is loaded dynamically, if that makes any difference) would be something along the lines of:

       

      sym.getComposition().getStage().gotoNextSlide("slide5");

       

      but no luck. I can alert the stage itself as [Object Object], which brings up another question. Is there an always-available property of objects that one can alert or trace to make sure the correct object is being targeted? I've had no luck with the symbol's id, name, or symbolName.

        • 1. Re: More syntax questions about nested symbols
          resdesign Adobe Community Professional & MVP

          Could you tell us more about your setup?

          Name of Symbol

          Name of label if your symbol contains labels to play

          Name of your function

          etc....

           

           

          or post your files.

           

          Usually you can access the stage from the symbol as you did.

          sym.getComposition().getStage().getSymbol('yourSymbolnamehere').play("labelsNameHere");

           

          Thanks.

          • 2. Re: More syntax questions about nested symbols
            John Hall Level 4

            Sure. You've seen one form of the project I'm working on, though I'm at the next speedbump. Here's an excerpt of the involved parts.

             

            I have the stage symbol and within that symbol, I have a function:

             

            function gotoSlide(slideName){

                      fadeTo(slideName);

            }

             

            function fadeTo(slideName){

                 /// this all works fine, when called from the main timeline

            }

             

            In the composition, I'm loading slides from the library and on the timeline of one of those slides is the following.

             

            navHidden = true;

            var trueButton = sym.getSymbol("answers").$("true");

            trueButton.bind('click',goNext);

             

            function goNext(){

                      sym.getComposition().getStage().gotoSlide("slide_05");

            }

             

            I know there are other syntaxes I could use but refactoring is in the future. The console log I get is:

             

            Object [object Object] has no method 'gotoSlide'

             

            It's slide 5 in these:

             


            • 4. Re: More syntax questions about nested symbols
              Endoplasmic Level 2

              change:

               

              function gotoSlide(slideName){

                        fadeTo(slideName);

              }

               

              to:

               

              sym.gotoSlide = function(slideName){

                        fadeTo(slideName);

              }

              • 5. Re: More syntax questions about nested symbols
                John Hall Level 4

                That simple! Endoplasmic, would you write a small companion book for ActionScript programmers to teach us the Edge API. So lets see if I have the concept straight. When I call the symbol from the nested script with the syntax:

                 

                sym.getComposition().getStage().gotoSlide("slide_05_true");

                 

                the first part of the call, the

                 

                sym.getComposition().getStage()

                 

                references the instance of the stage and at that point, if I have a script within the stage symbol, I want sym (which is now self referential to the stage itself) to run its function. Is that pretty much the concept behind it?

                 

                I think one problem I'm having is I'm used to working with JQuery but Edge abstracts the DOM and objects one more level or something that's confusing me.

                 

                Thanks again!

                • 6. Re: More syntax questions about nested symbols
                  Endoplasmic Level 2

                  John Hall wrote:

                   

                  That simple! Endoplasmic, would you write a small companion book for ActionScript programmers to teach us the Edge API. So lets see if I have the concept straight. When I call the symbol from the nested script with the syntax:

                   

                  sym.getComposition().getStage().gotoSlide("slide_05_true");

                   

                  the first part of the call, the

                   

                  sym.getComposition().getStage()

                   

                  references the instance of the stage and at that point, if I have a script within the stage symbol, I want sym (which is now self referential to the stage itself) to run its function. Is that pretty much the concept behind it?

                   

                  I think one problem I'm having is I'm used to working with JQuery but Edge abstracts the DOM and objects one more level or something that's confusing me.

                   

                  Thanks again!

                   

                  Haha! Yah the transition from ActionScript has been pretty awesome so far (no more compiling makes me happy).

                   

                  Yes that's right ("sym" and "this" are the same thing if that helps you understand it better). Basically anything that you want to publicly declare access to you put sym.methodName = function(){}, that way when you request the symbol via getSymbol that method is attached to that symbol.

                   

                  An easy way to think of it is that when you want to run a method on a symbol use sym.getSymbol('whatever') when you want to manipulate it using your traditional jQuery style just use sym.$('whatever') (which gives you your familiar jQuery methods)

                  • 7. Re: More syntax questions about nested symbols
                    John Hall Level 4

                    Yes that's right ("sym" and "this" are the same thing if that helps you understand it better).

                     

                    Yes, it definitely does! Why I could be programming in this before 2014, if I'm not careful.


                    • 8. Re: More syntax questions about nested symbols
                      Endoplasmic Level 2

                      Good! This is hands down the fastest way to whip up a protoype in HTML I've ever put my hands on (and ironically I've actually built a full on kiosk with it).

                       

                      Once you get the Edge API, stuff just becomes second nature.

                      • 9. Re: More syntax questions about nested symbols
                        resdesign Adobe Community Professional & MVP

                        Cool! This is going to be useful to many users here!

                        Thanks!