3 Replies Latest reply on Jun 23, 2015 11:56 AM by Zaxist

    access function

    zurik

      How can I access a function (function myFunction(){...}) that I have in the 'actions' on Stage, from a click event actions of one of the buttons? Thank you!

        • 1. Re: access function
          Zaxist Level 4

          you can have access to your functions by using variables like below :

           

          normal way is : ( have no access through click action )

           

          function myFunction (){

           

          // codes in here

           

          }

           

           

          the way we call it is :

           

          myFunction();

           

           

          Special way is : ( have access from every where )

           

          x = {

           

                    myFunction:function(){

                                       

                                        // codes will be here

           

                                        } // myFunction

           

          } // x our variable name can be anything

           

          the way we call it is :

           

          x.myFunction();

           

           

          and we can make functions with one variable as much as we want like below :

           

           

          x = {

           

                    myFunctionA:function(){

                                       

                                        // codes will be here

           

                                        },

           

                    myFunctionB:function(){

                                       

                                        // codes will be here

           

                                        },

                    myFunctionC:function(){

                                       

                                        // codes will be here

           

                                        }

           

          } // x our variable name can be anything

           

          the way we call it is :

           

          x.myFunctionA();

          x.myFunctionB();

          x.myFunctionC();

           

           

          i hope this can help you

           

          Zaxist

          1 person found this helpful
          • 2. Re: access function
            Allison@HavasLynx Level 1

            Your post here has helped me so much today Zaxist!

            I know this is an old post so maybe there is a different way of doing this for later versions of EA but I have been struggling to access functions from different timelines/symbols and this is working very well for me in v.2014.1.1!

            I haven't seen this anywhere else

            Many thanks

             

            • 3. Re: access function
              Zaxist Level 4

              you're welcome, i'm happy that i could help you

               

              regards

              Zaxist