質問

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