Child1Component.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="114" layout="absolute" title="Component 1">
<mx:Script>
<![CDATA[
protected function checkbox1_changeHandler(event:Event):void
{
if(chkShowHode.selected)
{
dispatchEvent(new Event("ShowClickEvent",true));
}else
{
dispatchEvent(new Event("ShowClickEvent",false));
}
}
]]>
</mx:Script>
<mx:CheckBox x="20" y="20" label="Show/Hide component 2" change="checkbox1_changeHandler(event)" id="chkShowHode"/>
<mx:Metadata>
[ Event(name="ShowClickEvent", type="flash.events.Event") ]
</mx:Metadata>
</mx:Panel>
//------------------------------------------
ChildComponent2.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="108" title="Component 2" layout="absolute">
<mx:Script>
<![CDATA[
protected function checkbox1_changeHandler(event:Event):void
{
if(chkShowHode.selected)
{
dispatchEvent(new Event("ShowClickEvent",true));
}else
{
dispatchEvent(new Event("ShowClickEvent",false));
}
}
]]>
</mx:Script>
<mx:CheckBox x="20" y="20" label="Show/Hide component 1" change="checkbox1_changeHandler(event)" id="chkShowHode"/>
<mx:Metadata>
[ Event(name="ShowClickEvent", type="flash.events.Event") ]
</mx:Metadata>
</mx:Panel>
//------------------------------------------
ParentComponent.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" width="590" height="380" layout="absolute" title="Parent" xmlns:views="com.flexpakistan.views.*">
<mx:Script>
<![CDATA[
protected function childcomponent1_ShowClickEventHandler(event:Event):void
{
if(event.bubbles == true)
{
comp2.visible = true;
}else
{
comp2.visible = false;
}
}
protected function comp2_ShowClickEventHandler(event:Event):void
{
if(event.bubbles == true)
{
comp1.visible = true;
}else
{
comp1.visible = false;
}
}
]]>
</mx:Script>
<views:ChildComponent x="10" y="25" ShowClickEvent="childcomponent1_ShowClickEventHandler(event)" id="comp1">
</views:ChildComponent>
<views:ChildComponent2 x="10" y="170" id="comp2" visible="false" ShowClickEvent="comp2_ShowClickEventHandler(event)">
</views:ChildComponent2>
</mx:Panel>
please feel free if u have any question to ask.