In the code below when I call chkAuthentication function from another function
the remoteObj.login (login function in my service file (.php)) is called after the remaining code in that function.
i.e., the loginStatus is returned from the function before the result-handler function loginResult is called. but my loginStatus is supposed to be set in loginResult function. It seems that the asynchronous behaviour is the culprit.
what should I do in order to get the loginResult function to complete first?
Please help me out. Thank you.
private var loginStatus:Boolean;
public function chkAuthentication(loginVOObj:LoginVO):String{
remoteObj.login.addEventListener(ResultEvent.RESULT,loginResult);
remoteObj.login(loginVOObj);
if(loginStatus == true){
return displayName;
}
else{
return 'fail';
}
}
private function loginResult(result:ResultEvent):void
{
if(result.result == null){
loginStatus=false;
}else{
loginStatus=true;
}
}