User Guide
Using Flash Remoting Update 9
When you click the Logout button, the application calls the setRemoteCredentials
method, which sets the username and password to null, and logs out the user on the client
side. In addition, the application calls the
logoutuser method, which handles server side
logout.
When you click the Get Secure Data button, the application calls the
getData method in the
MXML file, which, in turn, calls the
getData function in the CFC. The getData function in
the CFC returns a string for purposes of this simple test application, but could be modified to
return data such as the results of a query.
The Flex application also includes the
serverFault and serverResult methods, which
display an alert box to indicate whether the login was successful or not.
The MXML file appears as follows:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
layout="absolute">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.utils.ObjectUtil;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
private function logIn():void{
cf.setRemoteCredentials(this.username.text, this.password.text);
}
private function logOut():void
{
cf.setRemoteCredentials(null, null);
cf.logoutuser();
}
private function getData():void
{
cf.getData();
}
private function serverFault(event:FaultEvent):void{
Alert.show( ObjectUtil.toString(event.fault) );
Alert.show( "error" );
}
private function serverResult(event:ResultEvent):void{
Alert.show( ObjectUtil.toString(event));
Alert.show( "success" );
}
]]>
</mx:Script>