What is event bubbling in Flex? - apache-flex

What is event bubbling in Flex?

First, event bubbling is not specific to Flex, it's a feature related to AS3 event propagation.
Event propagation means the transference of a single event applying to multiple display objects. Each of those objects receives the event, instead of just the object in which the event originated.
I won't cover all the details of event propagation, google it for more info
(http://www.adobe.com/devnet/actionscript/articles/event_handling_as3_03.html)
Event bubbling means an event dispatched from a display object will bubble up the display list, starting from the object dispatching the event to the stage.
Notice that you can also use the capture phase to listen to an event dispatched by one of a display object's children. See my comment here

Related

Is there an a-frame event that fires after an entity is initialized?

I am looking for a way to detect when a new a-frames element has been added as a child of a given element(like "child-attached") but doesn't fire until the elements components have been initialized
alternatively, is there an event that is raised after an elements components have all been initialized?
The loaded event will fire when all components initialized. This event doesn't bubble. I would have a component that you attach to the dynamically added entities, and listen to load event. Better yet, set dependencies to wait for the exact component you need.
Related, the componentinitialized event will fire for each initialized component.

How to force flex to buble default event

subj, i need to listen for TooltipEvent of my far child. Is that possible without manual re-dispatching ?
You can try listening at the capture phrase. When adding the event listener in ActionScript there is an option to do so. If you do this your event listener will fire before the handlers that fire during the target phase.
Read a bit more about the event flow.

Flex components property change event

I have a custom component on which I have bound an array collection to one of its proeprties:
<comp:MyComp id="comp" prop="{images}" />
images is an arraycollection
In the components' code I would like to know which event to listen on everytime images updates props.I tried a setter on props but the setter only gets called once when props is first set. I tried the collection event but I get "Update" events sent on top of 'add' and 'remove' events and I would rather not have to manage those. So is there an event(flex or otherwise) that is fired every time a component property is updated by a bindable property?
I think you want to listen to the collectionChange event on the prop property. This should fire every time an element in your ArrayCollection changes.
Be warned that changing the source of images not fire the collectionChange event, nor will it fire the prop setter.

dispatch events between two advancedDataGrids

I have two separate advancedDataGrid instances (let's call them A and B). What I'd like to do: when clicking on grid A I'd like
for grid A to handle the click normally (i.e. default advancedDataGrid behavior)
for grid B to receive a click event a certain location and handle such event using advancedDataGrid default behavior (i.e. without having to write a handler for such click).
Is this possible?
I've managed to dispatchEvent a MouseEvent.CLICK to grid B and to handle such event by creating an event listener, but really I'd like for grid B to handle the event on its own (i.e. without having to re-rewrite a handler), and that doesn't seem to be the case. Is MouseEvent.CLICK even the right event?
any help, pointers, advice would be immensely appreciated.
thank you!
There is no way to execute code after an event is dispatched without using an event listener.
I'm unclear exactly what you're trying to do, but there is no reason why you can't dispatch an event on an object that is not it's own. Instead of doing:
myContainerWithAAndB.dispatchEvent(MouseEvent.CLICK);
You can do this:
gridB.dispatchEvent(MouseEvent.CLICK);
And if there is a default handler in the gridB class to handle such an event, that handler should fire; just as if gridB's own code had dispatched the event.

Flex event handling

I have added an event listener for a particular event, for e.g. CollectionEvent.COLLECTION_CHANGE. Inside that event listener, based on a certain condition, I want to call the default event handler for that event.
How is it possible? One way I can think of it is :
Inside the event listener :
If(Condition)
{
Remove event listener
dispatch event
add event listener again
}
This results in event overflow, which means that removing event listener is not
working. How to do it?
You can add multiple event listeners. Seems like you want to stop an event from propagating for certain conditions. For that you want one of these:
stopPropagation()
stopImmediatePropagation()

Resources