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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:57:49+00:00 2026-05-29T05:57:49+00:00

okay so here is my problem in my main project I’m trying to fire

  • 0

okay so here is my problem in my main project I’m trying to fire an event using dispatchEvent I’ve made a simple test class to test this and yet it still isn’t working…

Here is the test class

package 
{
import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite 
{
    public function Main() {

        stage.addEventListener("pOver", rake);


        dispatchEvent(new Event("pOver"));
    }


    public function rake(e:Event):void {

        trace("working");
    }

}

Why isn’t it firing? or why is the listener not capturing that event?

  • 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-29T05:57:50+00:00Added an answer on May 29, 2026 at 5:57 am

    You are dispatching the event on the Main, which is a child of Stage. If you want to specifically dispatch an event on the Stage then use:

    stage.dispatchEvent(new Event("pOver"));
    

    Now you may be wondering, “If it’s a child, then my event handler should still be getting triggered!”

    Well, yes and no.

    Lets take a look at a simple diagram of the event life-cycle:

    enter image description here

    First, the event that you are dispatching is not a bubbling Event. Examining the Event constructor, its signature looks like this:

    public function Event(type:String, bubbles:Boolean = false, cancelable:Boolean = false)
    

    Notice that the second argument is by default false, which means this event does not perform the bubbling part of the event life-cycle.

    Second, you have attached the event dispatcher on the bubbling side of the event life-cycle. If you look at the signature for .addEventListener() it looks like this:

    public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
    

    Notice the third argument. Which is by default false again. This means that you are attaching on the “bubbling” side of the event.

    This means that this event is getting to the targeted element, the instance of Main, and then stopping and not going anywhere else.

    TL;DR: So what does that all mean?

    So to trigger your event handler, and not change where the event gets dispatched, you need to change your event that you are triggering to:

    this.dispatchEvent(new Event("pOver", true));  // this event will bubble
    

    Then your event handler, since it is a child, will be triggered by this event.

    Conversely, I think that non-bubbling events will also progress through the capturing side of the event life-cycle so you could also change your event listener to attach to that side of the event as well.

    stage.addEventListener("pOver", rake, true); // attach to a capturing side
    

    I believe that event will always flow through the capturing phase, even if they are marked as not bubbling. But I could be wrong on that. I just can’t remember if “non-bubbling” events skip both capturing and bubbling phases and just trigger the target event phase and I don’t have time to check it right now.


    Edit

    So, I wrote up a quick test on wonderfl:

    package {
        import flash.events.Event;
        import flash.display.Sprite;
        public class FlashTest extends Sprite {
    
            private var debug:TextField;
    
            public function FlashTest() {
                stage.addEventListener("Foo", bubbleFooHandler);
                stage.addEventListener("Foo", captureFooHandler, true);
    
                trace("Ready");
    
                trace("---------------");
                trace("Trying a non-bubbling event");
                this.dispatchEvent(new Event("Foo"));
    
                trace("---------------");
                trace("Trying a bubbling event");
                this.dispatchEvent(new Event("Foo", true));
            }
    
            private function captureFooHandler(e:Event):void {
                trace("Triggered \"Foo\" from capturing phase\n");
            }
    
            private function bubbleFooHandler(e:Event):void {
                trace("Triggered \"Foo\" from bubbling phase");
            }
        }
    }
    

    The output from this is

    Ready
    ---------------
    Trying a non-bubbling event
    Triggered "Foo" from capturing phase
    ---------------
    Trying a bubbling event
    Triggered "Foo" from capturing phase
    Triggered "Foo" from bubbling phase
    

    Notice that events will always progress through the capturing phase. However, if they are not marked as a “bubbling event”, see before, they will descent through the tree they stop when they arrive at target of the event (the EventDispatcher the event was dispatched on).

    Bubbling events, on the other hand, will turn around and head back up the tree.

    Hopefully, this clears things up.

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

Sidebar

Related Questions

Okay, here is my problem... I created a Data Layer using the RTM Fluent
Okay, so here's my problem: We use FOP for creating pretty report output. We
Okay, so here's my problem: I have a list of members on a website,
Okay, so, here's what the problem is. I'm creating a flash site with each
I have a problem with (for me to complicated) MySql query. Okay, here is
Okay here's the program I have typed up(stdio.h is included also): /* function main
Okay so here is the deal. As the question states, I'm trying to POST
In Groovy code something simple: #!/usr/bin/env groovy public class test { boolean val def
Okay, I've encountered another problem with my simple program. My program gets the text
Problem: I'd like to specify the main class in a jar file that I

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.