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 7955803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:48:04+00:00 2026-06-04T03:48:04+00:00

I want to dispatch an Event 2 times: I have a MainClass, a SecondClass

  • 0

I want to dispatch an Event 2 times:

I have a MainClass, a SecondClass and a ThirdClass.

In the ThirdClass, there’s a clickEvent. I dispatch it to the SecondClass:

    this.addEventListener(MouseEvent.CLICK, clickHandler);


    public static const CLICKED_HANDLER:String = "clickedHandler";

    public function clickHandler(e:MouseEvent):void {
        dispatchEvent(new Event(CLICKED_HANDLER));
    }

I catch and throw it in the SecondClass:

    object.addEventListener(ThirdClass.CLICKED_Handler, clickedEventListener);


    public static const CLICKED_HANDLER:String = "clickedHandler";

    public function clickedEventListener(e:Event):void {
        dispatchEvent(new Event(CLICKED_HANDLER));
    }

And this I catch in the MainClass:

    object.addEventListener(SecondClass.CLICKED_HANDLER, clickedEventListener);

    public function clickedEventListener(e:Event):void {
        trace("click");
    }

But it wouldn’t work… What am I doing wrong?
And how could I get information about the object of the ThirdClass that’s clicked?
(Normaly with 1 dispatchEvent, it’s with:

    var thirdClassObject:ThirdClass = e.currentTarget as ThirdClass;

in the clickHandler method, but how to do this with 2 dispatchEvents?)

So: I want to know in my MainClass which ThirdClass-object is clicked.

Thanks a lot!

  • 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-06-04T03:48:07+00:00Added an answer on June 4, 2026 at 3:48 am

    When you dispatch an event, the target property references the dispatcher.
    What you apparently need is passing a reference to third class along with the event to use in the event handler of main class.

    You have several options to achieve this.

    1. If a dispatcher instance is on the display list, use event bubbling to handle events in parent display objects. Refer to the second argument of Event constructor and Event.bubbles property. This way you can subscribe to any events of child objects in a parent, and check Event.target property in your event handler. Most of mouse events like MouseEvent.CLICK are bubbling by default. So you could just listen to them and check targets in main class.

      // inside MainClass
      // notice: we are subscribing to MainClass instance
      this.addEventListener(MouseEvent.CLICK, clickedEventListener);
      public function clickedEventListener(e:MouseEvent):void { trace(e.target); // the target is what was actually clicked // you may also notice the difference between e.target and e.currentTarget }

      If you still want to use CLICKED_HANDLER event, you may do so as follows:

      // inside ThirdClass
      dispatchEvent(new Event(CLICKED_HANDLER, true));
      // ---------------------------------------^

      Remember: this will only work for display list members.
      See the Event flow article on adobe.com.

    2. Create a custom event class and place reference there. (And you can also use event bubbling with custom event classes.) This way you will dispatch your event as

      // inside SecondClass
      public function clickedEventListener(e:Event):void {
          var customEvent:CustomEventClass = new CustomEventClass(CLICKED_HANDLER);
          customEvent.customTarget = e.target;
          dispatchEvent(customEvent);
      }
      // inside MainClass public function clickedEventListener(e:CustomEventClass):void { trace(e.customTarget ); }

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

Sidebar

Related Questions

i have a tlf text input in stage,i want dispatch ahndler for this object
I want to dispatch a custom event when the two files are downloaded or
I have an event listener for a custom event type. This custom event overrides
I'm using the combobox component and I want to manually dispatch the change event.
i have a problem with my application tha some times return this error in
I want to have a single event listener for multiple events and depending on
I have several different 'types' of incoming events, and I want to dispatch them
I want to setup a Method dispatch table and I am wondering if it
Want to do this: (EDIT: bad sample code, ignore and skip below) struct RECORD
want to have a Hyperlink-Button in a gridView in which I can display a

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.