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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:03:58+00:00 2026-05-19T09:03:58+00:00

I’m seeing some weirdness in event bubbling, which suggests I don’t really understand how

  • 0

I’m seeing some weirdness in event bubbling, which suggests I don’t really understand how this is supposed to work.

I have a component which extends DataGroup, and it’s item renderer dispatches an event (which bubbles).

// MyRenderer.mxml
<s:ItemRenderer>
    <s:Button click='dispatchEvent(new Event('customEvent',true))' />
</s:ItemRenderer>

The DataGroup adds a listener for the event to itself.

// MyDataGroup.mxml
<s:DataGroup  itemRenderer="MyRenderer" creationComplete='onCreationComplete()'>
   <fx:Metadata>
       [Event(name='customEvent',type='flash.events.Event')]
   </fx:Metadata>
   <fx:Script>
      private function onCreationComplete():void
      {
          addEventListener('customEvent',onCustomEvent);
      }
      private function onCustomEvent(event:Event):void
      {
      }
   </fx:Script>
</s:DataGroup>

The Parent of the datagroup is also adding a listener for the event.

// MyComponent.mxml
<s:Group>
    <MyDataGroup customEvent='onCustomEventHandler()' />
</s:Group>

I’d have expected that the handler registered in MyDataGroup should catch the event first, then the handler in MyComponent.

However, I’m seeing the reverse – ie., caught in MyComponent, then in MyDataGroup. When caught, event.phase == EventPhase.BUBBLING.

What’s going on here? Why am I seeing this behaviour?

I’m using Flex 4.0.

  • 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-19T09:03:58+00:00Added an answer on May 19, 2026 at 9:03 am

    I’m pretty sure the problem is that both of your event listeners are listening to the same instance on the MyDataGroup component.

    If you add the an event listener to MyComponent instead of MyDataGroup, you’ll get expected behavior:

    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
             xmlns:s="library://ns.adobe.com/flex/spark" 
             xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300" 
              initialize="group1_initializeHandler(event)">
        <fx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                import mx.events.FlexEvent;
                public function onCustomEventHandler(event:Event):void{
                    trace('my Component handler');
                }
    
                protected function group1_initializeHandler(event:FlexEvent):void
                {
                    // add the event listener to 'this' 
                    this.addEventListener('customEvent',onCustomEventHandler);
                }
    
            ]]>
        </fx:Script>
        <martyPitt:MyDataGroup id="dataGroup"  />
        <!-- The event listener here was listening on the myDataGroup instance, not on the MyComponent instance customEvent="onCustomEventHandler(event)"  -->
    </s:Group>
    

    I suspect the event listeners–even though not in the same component–were firing based on the order they were added. You’d have to examine the generated ActionScript with the compiler argument ‘-keep’ to figure that out specifically. I suspect your in-line listener (MyComponent) is added in the MyDataGroup constructor. Since the other listener is added in the MyDataGroup a creationComplete handler, the MyComponent listener fires first.

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

Sidebar

Related Questions

I have some data like this: 1 2 3 4 5 9 2 6
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I have a French site that I want to parse, but am running into
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put

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.