문제

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