You want to add the listener to the thing that dispatches the event, the
application, and declare the handler in the component.

 

Application.application.addEventListener("buttonLabelEvent",
buttonLabelHandler);

You will need to import the custom event.

 

 

 

Tracy Spratt,

Lariat Services, development services available

  _____  

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of edencane
Sent: Wednesday, September 16, 2009 4:07 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] child component listens for event on parent

 

  


I was able to get the event happening by changing the component code to be:

private function postInit():void {
Application.application.addEventListener("buttonLabelEvent",
buttonLabelHandler);
}

but now the event seems to trigger 3 times for every tab change but doesnt
trigger on the first tab change...

And the app takes forever to compile as well...

Something still not right..

Please help..

edencane wrote:
> 
> Hi.
> 
> Im trying to get a child component to listen for an event that happens on
> tabchange in the parent.
> The parent is an application with a TabNavigator object.
> When the tabchanges I want the the child component to carry out some
> stuff.
> 
> In the parent Ive got:
> <mx:Metadata>
> [Event(name="buttonLabelEvent", type=" flash.events.Event")]
> </mx:Metadata>
> 
> then in the tabChange function Ive got:
> var bLEvent:Event = new Event("buttonLabelEvent");
> dispatchEvent(bLEvent);
> 
> Now I want to listen for this event in a child component.
> There are several instances of the childcomponent (which is basically a
> form containing a combobox) in the main application.
> I want every instance of the childcomponent to listen and act when a
> tabchange occurs in the main component.
> 
> So far in the component I have:
> creationComplete="postInit()"
> Then in postInit I have:
> this.addEventListener(Application.application.buttonLabelEvent,
> buttonLabelHandler);
> 
> However, this is not right.
> 
> how do I do this...?
> 
> Thanks for help...
> Kind regards.
> Luke Vanderfluit.
> 
> 

-- 
View this message in context: http://www.nabble.
<http://www.nabble.com/child-component-listens-for-event-on-parent-tp2546673
4p25467780.html>
com/child-component-listens-for-event-on-parent-tp25466734p25467780.html
Sent from the FlexCoders mailing list archive at Nabble.com.



Reply via email to