Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 935777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:12:37+00:00 2026-05-15T21:12:37+00:00

so today my question is how can we have 1 function triggered by both

  • 0

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.

Issue:

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)

I’m hoping this there is an easy workaround for this like event:null or something.

The Timer Event:

private function overShareButton(event:MouseEvent):void
    {
        shareIconsTimer = new Timer(3000,1);
        shareIconsTimer.addEventListener(TimerEvent.TIMER, fadeOutShareIcons);
        shareIconsTimer.start();

        fadeInShareIcons();
    }

The close button event:

shareIcons.btn_closeIcons.addEventListener(MouseEvent.MOUSE_UP, fadeOutShareIcons);

The addThis Bubble Fade out function:

// 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 & 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});
    }

My only choice right now is to create another function to handle the close button MouseEvent, any tips/thoughts appreciated! 😀

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T21:12:37+00:00Added an answer on May 15, 2026 at 9:12 pm

    Your problem here is you have typed your fadeOutShareIcons argument to a TimerEvent, so it can only accept TimerEvent.

    Since MouseEvent and TimerEvent descend from Event you can use it so both can work together. If you want also call the same function without argument you can pass a default value setted to null.

    • case 1

      private function fadeOutShareIcons(e:Event):void
      
    • case 2 with default argument so you can call fadeOutShareIcons()

      private function fadeOutShareIcons(e:Event=null):void
      
    • You can also check from where event you came checking the type of the event:

      private function fadeOutShareIcons(e:Event=null):void {
        if (e==null) {
          // call directly
        } else if (e.type==MouseEvent.MOUSE_UP) {
            // came from mouse event
        } else if (e.type==TimerEvent.TIMER) {
            // came from timer event
        }
        //...
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 479k
  • Answers 479k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer While I would normally not suggest dropping to low level… May 16, 2026 at 5:49 am
  • Editorial Team
    Editorial Team added an answer This is a classic little problem that is usually solved… May 16, 2026 at 5:49 am
  • Editorial Team
    Editorial Team added an answer If your collection object is a TCollection, then it has… May 16, 2026 at 5:49 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.