It will depend on where and how the listener is declared.
CreationComplete fires at different times for different components.  As
I recall, it is bottom up, so creationComplete for a parent will fire
after creationComplete for a child.  If the parent creationComplete
handler declares the listener, then there would be a problem.

 

This should only be an issue on start-up.  Certainly the listener would
be available when the app was ready to receive user input, via ComboBox
or button click, as the original poster noticed.

 

Remember that events flow through the DOM.  It is possible for a
dispatched event to "miss" a component.  Pop-ups are a particular
problem.

 

Tracy

 

________________________________

From: [email protected] [mailto:[email protected]] On
Behalf Of stldvd
Sent: Monday, January 05, 2009 4:48 PM
To: [email protected]
Subject: [flexcoders] Re: why I can not dispatchEvent with
creationComplete?

 

I'm having a similar issue. Event is dispatched (I can step through
code and see it) but the event listener is never hearing it, and so
the listener function is never being fired.

How does one tell if the listener is ready or not? If you add the
listener on the creationcomplete or initialize event of an mxml
component, it should in theory be ready to fire, for the duration of
the app, right? And if you're dispatching a custom event when an item
is selected in a combobox, it should certainly work. What could be the
reason for a 'deaf' event listener? :)

-- David

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Tracy Spratt" <tspr...@...> wrote:
>
> Perhaps the listener is not yet ready when the canvas creationComplete
> fires?
> 
> Tracy
> 
> 
> 
> ________________________________
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of markflex2007
> Sent: Monday, January 05, 2009 2:08 PM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] why I can not dispatchEvent with
creationComplete?
> 
> 
> 
> I try the following code, But I can not dispatchEvent.
> 
> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> 
> <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > "
> creationComplete="justLogin()" >
> <mx:Metadata>
> [Event(name="loginEvent", type="flash.events.Event")]
> </mx:Metadata>
> <mx:Script>
> <![CDATA[
> 
> 
> private function justLogin():void{ 
> 
> dispatchEvent(new Event("loginEvent", false));
> 
> }
> ]]>
> </mx:Script> 
> 
> </mx:Canvas>
> 
> I can dispatchEvent with button click, please let me know how to
> automatic dispatchEvent in page start.
> 
> Thanks
> 
> Mark
>

 

Reply via email to