1 Reply Latest reply on Aug 14, 2009 12:47 AM by dalcde

    Calling the on(press) event handler

    zeldalink

      Preface

       

      Typically when you set an event handler function for buttons by code, like:

       

      mybutton.onPress = function(){

               trace("Hello!");

      }

       

      you can access and call this event handler function by:

       

      mybutton.onPress();

       

       

      and it will execute the function and trace "Hello!".

       

       

      Question

       

      But when you set event handlers on the button itself, like:

       

      on(press){

               trace("Hello!");

      }

       

      is that event function accessible from code? how? I know there would be a property that you can access it by, maybe we can "decompile" an SWF to check out finally which property it stores the event code in, or would any of you have any idea?

       

      mybutton.onPress();   // This does not work!

        • 1. Re: Calling the on(press) event handler
          dalcde Level 1

          I don't know why, but I think it is like this. When you call the onPress() function, it will find a function called onPress, which is the onPress = function(). If you are just curious to know the answer, it is fine. If you really want to solve the problem, make a function ( for example pressed), and use mybutton.pressed(). And at the on(press) code, simply add pressed();