It sounds like you want to be able to register on a object high up in
the DisplayObject tree -- such as the Stage, the SystemManager, or the
Application -- and detect when DisplayObjects have been added anywhere
below, no matter how deep down.
 
To figure out how to do this, let's consider the four different events
that convey information about children getting added:
 
Event.ADDED: Dispatched from DisplayObject that was added. Bubbles up
the parent chain.
 
Event.ADDED_TO_STAGE: Dispatched from DisplayObject that was added.
Doesn't bubble up the parent chain.
 
FlexEvent.ADD: Dispatched from a UIComponent that was added as a content
child to a Container.Doesn't bubble up the parent chain.
 
FlexEvent.CHILD_ADD: Dispatched from a Container to which a content
child was added. Doesn't bubble up the parent chain.
 
Also, keep in mind that, although not all events bubble, they all go
through a "capture" phase that is the opposite of bubbling -- starting
at the SystemManager and going down the parent chain to the event
target. To listen to events passing through a DisplayObject during the
capture phase, set the useCapture parameter of addEventListener() to
true.
 
So I think your choices are either to listen on Stage, SystemManager, or
Application for any of these four events on their way down to the target
during the capture phase, or for Event.ADDED on these objects as it --
the only one that bubbles -- bubbles up.
 
Gordon Smith
Adobe Flex SDK Team

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Sherif Abdou
Sent: Thursday, January 17, 2008 6:08 PM
To: [email protected]
Subject: [flexcoders] detect when a child has been added



<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" creationComplete="initApp()">

<mx:Script>

<![CDATA[

private function initApp():void{

var t:Text = new Text();

t.text="FlexCoders";

this.addChild(t);

this.systemManager.addEventListener(FlexEvent. ??? What do i
use,function(){

trace('here'); // i want to detect whenever something has been added to
the stage/application but Event.ADDED_TO_STAGE does not work an neither
FlexEvent.ADD

});

} 

]]>

</mx:Script>

</mx:Application>


________________________________

Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try
it now.
<http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i6
2sR8HDtDypao8Wcj9tAcJ>  

 

Reply via email to