I add here, as you want, a snippet of code about logout from application:
public function logoutApplication(isSessionDown:Boolean=false):void
{
// This method close other open windows (because in AIR you can open more than one window)
closeOtherWindows();
// Here I want to manage a sessionExpired variable in model locator so I can use for further aim
if (CoreML.getInstance()!=null && CoreML.getInstance().sessionExpired){
ModelLocator.getInstance().sessionExpired=true;
CoreML.getInstance().sessionExpired=false;
}
// Here I remove all opened popup
var listPopUp:IChildList = FlexGlobals.topLevelApplication.systemManager.popUpChildren;
for (var i:int = 0; i < listPopUp.numChildren; i++) {
var curr:IFlexDisplayObject = listPopUp.getChildAt(i) as IFlexDisplayObject;
try {
if (curr != null) {
PopUpManager.removePopUp(curr);
}
}
catch(ex:ExceptionFrontEndHandler) {
// If you arrive here, it isn't a popup
}
}
// here I update my component menu (it's business logic is not important)
if (this.cntComponentMenu != null) {
var newMenuComp:ComponentMenu = new ComponentMenu();
newMenuComp.container=this;
this.cntComponentMenu.removeAllElements();
this.cntComponentMenu.addElement(newMenuComp);
}
// Here I change the state of my main MXML to login and clean the text box (not binded with BO)
this.currentState='login';
if (this.cntLogin!=null){
this.cntLogin.currentState='State1';
this.cntLogin.validateNow();
this.cntLogin.userId.text="";
this.cntLogin.password.text="";
}
if (!isSessionDown) EnvDispatcher.resetInfoSession(this);
else mypackage.ModelLocator.getInstance().logout=true;
}
Here the code in result command of EnvDispatcher.resetInfoSession:
if (this.evt.sender!=null && this.evt.sender is UncertaintyAIR) {
var pnl:MyApplication = this.evt.sender as MyApplication;
pnl.currentState='login';
pnl.validateNow();
pnl.groupLogin.removeAllElements();
LoginDispatcher.logout();
LoginDispatcher.logoutSecure();
mypackage.ModelLocator.getInstance().logout=true;
var loginView:LoginView = new LoginView();
loginView.container=pnl;
pnl.groupLogin.addElement(loginView);
}
sessionManager.logout()
method which is Flex code which is working for flash project .In Adobe Air do we have any session object or we have to remove all the components one by one – Subodh Joshi