3 Replies Latest reply on Jun 13, 2013 2:57 AM by AMULI

    Calling a function inside a symbol?

    abnesher Level 1

      Hi there,

       

      I'm one of those flash-devs that are trying to get Edge Animate to do what I usually do in Flash, so I might be doing this the wrong way, but I've got a symbol with a function "inside" on my stage, and I wanna call that function from the stage.

       

      I've been trying to use sym.getComposition().getStage().getSymbol("symbolName").functionName(); but it doesn't work.

       

      I don't have any problems manipulating the symbol itself by calling .play() or .hide() so I know the path works....can anyone show me the right syntax to call a function inside a symbol?

       

      Thx in advance

        • 1. Re: Calling a function inside a symbol?
          AMULI Level 4

          Hi Abnesher,

           

          An important principle to grasp is that symbols (and the stage is one of them) lies in parallel, despite the fact of instances of different symbols being nested one in another (and all in fine nested in the stage).

           

          The consequence is that from inside your nested symbol you have no direct visibility of the function defined inside the stage symbol !

           

          Inside the Stage symbol, in the document.compositionReady event handler :

           

          sym.yourGlobalFunction = function( firstParameter)

          {

            // your stuff

          }

           

          Inside another symbol, in one of its events handlers :

           

          sym.getComposition().getStage().yourGlobalFunction( 5);

           

          Gil

          • 2. Re: Calling a function inside a symbol?
            abnesher Level 1

            Thx for the quick reply!

             

            I never saw the compositionReady part of the stage, which made what I want to do alot easier.

             

            So instead of putting functions inside symbols, it is better to put them in the compositionReady event handler? (I can imagine this would be best practice most places, but I'm just so used to dividing it all up in parts in Flash)

            • 3. Re: Calling a function inside a symbol?
              AMULI Level 4

              So instead of putting functions inside symbols, it is better to put them in the compositionReady event handler?

               

              When they are of general interest, and susceptible to be called from different locations : yes.

               

              I'm just so used to dividing it all up in parts in Flash

               

              I would leave inside a symbol a function that is not used outside, to get things more properly encapsulated.

               

              Gil