I was wondering if it was possible to call two different functions from one mouse event, like click. I figured it might just be something like:

    button.addEventListener(MouseEvent.CLICK, function1 && function2);

Unfortunately that doesn't work. Do i need to call a new function that contains those two? For example

   button.addEventListener(MouseEvent.CLICK, function3);
   function function3(){
       function1();
       function2();
   }

The latter seems very inefficient so i assume there is a way to do it like the prior.

有帮助吗?

解决方案

You can either do that or register two Click event handlers, or you could write the function inline (inside the addEventListener) such as

button.addEventListener(MouseEvent.Click, function(e:Event):void {
      function2();
      function3();
}):
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top