8 Replies Latest reply on Feb 25, 2014 1:02 AM by hemanthR

    global variable

    S Hopkins Adobe Community Professional

      Sorry to ask but...

      I have a symbol on the stage. I need to know its Y-coordinate relative to the stage. Accessing it from the symbol returns a relative value of 0.

      offset().top returns 0.

      I can get the top coordinate from the stage:

      sym.myPosition = sym.$("mySymbol").css("top");


      I think I have tried every possible permutation for accessing the value from the symbol:

      Everything I have tried (including answers given here) all return "not defined".


      I have tried using globals with

      getComposition().getStage().myPosition; with and without sym

      I have tried using getComposition().getStage().getVariable with and without sym, 


      It is defined at the stage level.


      I give! Any help???

      S. Hopkins

        • 1. Re: global variable
          S Hopkins Adobe Community Professional

          DUH! I had Applied checked instead of global. With global scope, offset().top returns the absolute position for the symbol:


          var myTop = sym.$("mySymbol").offset().top;


          However, It would be nice to find out how to get a variable value from the stage when using document.compositionReady. (Remember reading somewhere that compositionReady required "special handling.")


          Thanks all,



          • 2. Re: global variable
            elainecc Adobe Employee

            Hi, S. Hopkins-


            In compositionReady, you can simply refer to the stage as sym.  So if you need to get data via jQuery, it would look like:


            var myColor = sym.getSymbolElement().css('background-color');


            Hope that helps,



            1 person found this helpful
            • 3. Re: global variable
              S Hopkins Adobe Community Professional

              Hi Elaine,


              Your example works. But where I am having problems is with position/offset/top.

              Yes, I am still struggling with it. I think it's a bug (but maybe its me).

              I thought I had it working. Then I created a new composition, and the same code failed--and yes I have Global set. Went back to the old project, and it now does not work. I just keep getting the value of 0--should be 100. I now get the same result with Applied as I do with Global.


              Is there somehow I can set the Global state via code to see if that will fix the problem?


              Thanks for your help,



              • 4. Re: global variable
                Zaxist Level 4

                can you tell me where is the location on this div or Symbol ( mySymbol ) in your Edge project ?



                • 5. Re: global variable
                  S Hopkins Adobe Community Professional

                  The symbol is a direct child of the main stage. (I think that is what you were asking.)

                  Thanks for replying,


                  • 6. Re: global variable
                    hemanthR Adobe Employee

                    Iam getting right value with the below code added on composition ready.



                    If this is not working for you.Can you post/PM your files?

                    1 person found this helpful
                    • 7. Re: global variable
                      S Hopkins Adobe Community Professional

                      rhemanthkumar: Yes, this works.


                      Here is the problem. I have a symbol that I want to reuse as an ANSYM file. Therefore, I need to have the code inside the symbol. I could resort to using the stage to get the coordinates for the symbol. (Prefer not.) This is the reason for my question: is there someway I can get the value for a global variable into my symbol (on creation complete). This I would think would be similar to using getters and setters but sym.getVariable and sym.setVariable don't work.


                      The best solution would be to be able to get the values for coordinates from within the symbol itself. Any ideas are appreciated.


                      Thanks for answering,



                      • 8. Re: global variable
                        hemanthR Adobe Employee

                        You could query the element top value of symbol at 0th second trigger in a symbol.

                        This returns the top value of the symbol w.r.t stage.


                        Add this code in a trigger on the '0'th second  within the symbol

                        var ele = sym.getSymbolElement();



                        Hope this works!

                        1 person found this helpful