I have a RemoteObject that is firing when a button is clicked.  I want the 
button that is clicked to disappear and another button to appear if the result 
coming back from the remoteObject is true.

What happens is I click the button with a correct login and password (that does 
return the reServalent.Authuser.lastResult as TRUE) and nothing changes.  I 
click the button again and then it works.  My auth button disappear and my 
clockinbutton appears.

Why do I need to press the button twice?  If the roServalent.authUser() is slow 
to retrieve results will the if/else function run without waiting for 
roServalent.authUser.lastResult to return a value?
 

private function authorizeUser():void{
        roServalent.authUser()
        
        if (roServalent.authUser.lastResult == true) {
                authButton.visible = false;
                clockInButton.visible = true;
        }else{
                authButton.visible = true;
                clockInButton.visible = false;
        }
}


<mx:RemoteObject id="roServalent" destination="ColdFusion" 
source="local.careycolor.servalent.login"
        endpoint="http://demo.dev/flex2gateway/";> 
        
    <mx:method name="authUser">
        <mx:arguments>
            <login>{login.text}</login>
                <pwd>{pwd.text}</pwd>
        </mx:arguments>
    </mx:method>
</mx:RemoteObject>


<mx:TextInput x="94" y="47" id="login" text="login"/>
<mx:TextInput x="94" y="73" id="pwd"  text="pwd" displayAsPassword="true"/>

<mx:Button id="authButton" x="134" y="98" label="Login" click="authorizeUser()" 
visible="true"/>

<mx:Button id="clockInButton" x="134" y="207" label="Clock In" visible="false"/>

Reply via email to