this is my code
import mx.containers.TitleWindow;
private function closeWindow(event:Event):void{
removeChild( event.target as TitleWindow);
currentState='';
}
then on the titlewindow component this is the way i call the close function
<mx:State name="login_reg">
<mx:RemoveChild target="{intro}"/>
<mx:AddChild relativeTo="{intro_container}">
<mx:target>
<comp:login_register id="login_reg"
close="closeWindow(event)" loginSuccessful="handleLoginSucess(event)"/>
</mx:target>
</mx:AddChild>
</mx:State>