Pergunta

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.

Foi útil?

Solução

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();
}):
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top