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

  • SEARCH
  • Home
  • 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 6738509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:22:39+00:00 2026-05-26T11:22:39+00:00

How to call removeEventListener when I don’t know the function which is the event

  • 0

How to call removeEventListener when I don’t know the function which is the event handler?

  • 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-26T11:22:39+00:00Added an answer on May 26, 2026 at 11:22 am

    You should create your own implementation of EventDispatcher. It’s sad but native IEventListener prototype doesn’t provide lots usefull methods.

    There is a sample code of how that implementation would look like:

    package {
    import flash.events.EventDispatcher;
    import flash.utils.Dictionary;
    
    /**
     * Advanced Event Dispatcher with a ability to remove all listener by event type
     * @author  Rytis Alekna
     */
    public class AdvancedEventDispatcher extends EventDispatcher {
    
        /** This var holds all references to listeners */
        protected var eventListenersByType : Dictionary = new Dictionary( true );
    
        /**
         * Call this method to remove all listeners of specified type
         */
        public function removeEventListenersByEventType ( type : String, useCapture : Boolean = false ) : void {
    
            var key : String = type + ":" + useCapture;
    
            if ( this.eventListenersByType[ key ] && this.eventListenersByType[ key ].lenght > 0 ) {
    
                // copy array of event listeners
                var listenersToRemove : Array = this.eventListenersByType[ key ].concat();
    
                // and clear original 
                this.eventListenersByType[ key ] = [];
    
                // loop over all listeners
                for ( var i : int = 0; i < listenersToRemove.length; i++ ) {
                    this.removeEventListener( type, ( removeEventListenersByEventType[i] as Function ), useCapture );
                }
    
            }
    
        }
    
        /**
         * Override this method to implement listeners registration by type.
         */
        override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false) : void  {
    
            // register with native method
            super.addEventListener(type, listener, useCapture, priority, useWeakReference);
    
            // create a key for storage
            var key : String = type + ":" + useCapture;
    
            // check if it doesn't already exist
            if ( !this.eventListenersByType[ key ] ) {
                this.eventListenersByType[ key ] = [];
            }
    
            // push listener to our storage
            this.eventListenersByType[ key ].push( listener );
    
        }
    
    }
    

    }

    Otherwise as you mentioned that in your case you need to fire event only once than you can use such a handy framework like AS3 Signals (http://johnlindquist.com/2010/01/21/as3-signals-tutorial/)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I call the following function with a mouseover event but it's not working. My
Call to a member function save() on a non-object in .../views/manufacturer/tmpl/edit.php line 24 which
The call to n.sort(sortNo) doesn't specify any parameters for the function sortNo (which defines
I call my JavaScript function. Why do I sometimes get the error 'myFunction is
I call a javascript function from a textbox by using OnKeyPress=clickSearchButton() Here is my
I call: [[ UIApplication sharedApplication ] setIdleTimerDisabled: YES ] on the applicationDidFinishLaunching event.. I
I call an ajax enabled wcf service method , <script type=text/javascript> function GetEmployee() {
I call a service which returns a gzipped file. I have the data as
To call, for example, a function named makeRequest, I learned you need to do
Hey guys so I've got a working Timer, which will stop() when I call

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.