title: How to use the same function for both a Timer event and Mouse event in AS3?
body: <p>so today my question is how can we have 1 function triggered by both a Timer event and a Mouse event? 'm trying to avoid having to re-write/re-name a function just because I also have a Mouse event that triggers it and not just a Timer event.</p>
  
  <p>Issue:</p>
  
  <p>I have a addThis bubble fade in with icons on a button rollover, the addThis bubble will fade out after the timer is finished, but I also have a close button in that bubble which needs to use the same function that the timer uses. (want to avoid writing 2 exactly alike functions)</p>
  
  <p>I'm hoping this there is an easy workaround for this like event:null or something.</p>
  
  <p>The Timer Event:</p>
  
  <pre><code>private function overShareButton(event:MouseEvent):void
      {
          shareIconsTimer = new Timer(3000,1);
          shareIconsTimer.addEventListener(TimerEvent.TIMER, fadeOutShareIcons);
          shareIconsTimer.start();
  
          fadeInShareIcons();
      }
  </code></pre>
  
  <p>The close button event:</p>
  
  <pre><code>shareIcons.btn_closeIcons.addEventListener(MouseEvent.MOUSE_UP, fadeOutShareIcons);
  </code></pre>
  
  <p>The addThis Bubble Fade out function:</p>
  
  <pre><code>// Fade out the addThis Icons
      private function fadeOutShareIcons(e:TimerEvent):void
      {
          shareIcons.buttonMode = false;
  
          shareIcons.btn_closeIcons.buttonMode  = false;
          shareIcons.btn_email.buttonMode       = false;
          shareIcons.btn_facebook.buttonMode    = false;
          shareIcons.btn_myspace.buttonMode     = false;
          shareIcons.btn_digg.buttonMode        = false;
          shareIcons.btn_delicious.buttonMode   = false;
          shareIcons.btn_favorites.buttonMode   = false;
          shareIcons.btn_twitter.buttonMode     = false;
          shareIcons.btn_google.buttonMode      = false;
          shareIcons.btn_messenger.buttonMode   = false;
          shareIcons.btn_stumbleupon.buttonMode = false;
  
          // STOP TIMER &amp; Remove share icon button events...
          shareIconsTimer.stop();
          shareIconsTimer.removeEventListener(TimerEvent.TIMER, fadeOutShareIcons);
          shareIcons.btn_email.removeEventListener       (MouseEvent.MOUSE_UP, addThisToEmail);
          shareIcons.btn_facebook.removeEventListener    (MouseEvent.MOUSE_UP, addThisToFacebook);
          shareIcons.btn_myspace.removeEventListener     (MouseEvent.MOUSE_UP, addThisToMyspace);
          shareIcons.btn_digg.removeEventListener        (MouseEvent.MOUSE_UP, addThisToDigg);
          shareIcons.btn_delicious.removeEventListener   (MouseEvent.MOUSE_UP, addThisToDelicious);
          shareIcons.btn_favorites.removeEventListener   (MouseEvent.MOUSE_UP, addThisToFavorites);
          shareIcons.btn_twitter.removeEventListener     (MouseEvent.MOUSE_UP, addThisToTwitter);
          shareIcons.btn_google.removeEventListener      (MouseEvent.MOUSE_UP, addThisToGoogle);
          shareIcons.btn_messenger.removeEventListener   (MouseEvent.MOUSE_UP, addThisToLive);
          shareIcons.btn_stumbleupon.removeEventListener (MouseEvent.MOUSE_UP, addThisToStumbleupon);
  
          TweenLite.to(shareIcons, .2, {alpha:0});
      }
  </code></pre>
  
  <p>My only choice right now is to create another function to handle the close button MouseEvent, any tips/thoughts appreciated! :D </p>