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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:05:22+00:00 2026-06-13T23:05:22+00:00

I found something strange while I was coding today. I couldnot find explenation of

  • 0

I found something strange while I was coding today. I couldnot find explenation of what happend to me today.

I have created button and addEventListener to it.

private function drawButtons():void{
        survivorModeBtn = new SurvivorModeBtn();    
        trace("I registered Event Listener with button here");
        survivorModeBtn.addEventListener(MouseEvent.CLICK,onSurvivorModeBtnClick);
        addChild(survivorModeBtn);
}

private function onSurvivorModeBtnClick(e:MouseEvent):void{
        trace("I clicked on btn here");
        //I will dispatch event here which runs second part of code
        mainMenuViewEvent = new MainMenuViewEvent("onSurvivorModeIsClicked");
        hideButtons();
        dispatchEvent(mainMenuViewEvent);
}

Dispatched event will run those parts of code:

public function createClickToStart():void{
        trace("here I register event listener MouseEvent.Click");
        stage.addEventListener(MouseEvent.CLICK,onClick);
    }

private function onClick(e:MouseEvent):void{
        trace("onClick()");
    }

When I run my program and Click on first button. I got this output in console:

I registered Event Listener with button here
I clicked on btn here
here I register event listener MouseEvent.Click
onClick()

I can t understand how can I see “onClick()” msg, if I clicked just on first button, and even in that time was not stage redistered with CLICK event.

Thank you for solution to my problem.

  • 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-13T23:05:22+00:00Added an answer on June 13, 2026 at 11:05 pm

    You have experienced what is called “bubbling” of an event. First, the “click” event is dispatched to the topmost object under cursor, then it raised upwards via parent references all the way to stage, if you don’t force it to e.stopPropagation(). So, while the event was being parsed within survivorModeBtn, it has not yet reached stage, an in the meantime you ssign stage listener for this type of events. Then it bubbles up and hits stage, stage says “Wow, I have a MouseEvent.CLICK listener registered, let’s call it right now!” and calls onClick() function, making you receive your last trace result.

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

Sidebar

Related Questions

I have just found something very weird while developing a website. While trying to
I found something strange while debugging some code. Apparently, >>> (0-6) is -6 False
While answering this question I found some strange behavior for which I have no
I was working on a demo method and found something strange(at least to me
I happened to something strange to me on CALayer.And finally found the CALayer's frame.size
I was playing around with include and extend today and found something I don't
I'm searching a while for this and I can't found something that works for
I've been experimenting with CSS3 and found something strange. Heres's the part of DIV
I found something strange in my application. Gonna be hard to describe my prob
I was working on an android project, and while designing i noticed something strange

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.