java
Java代码
package com;
public class LoginDemo {
public String validate(String usernameString password){
String message =login failed!;
if(usernameequals(lin)&&passwordequals(lin)){
message = login successed!;
}
return message;
}
}
remotingconfigxml
Java代码
<?xml version= encoding=UTF?>
<service id=remotingservice
class=ssagingservicesRemotingService>
<adapters>
<adapterdefinition id=javaobject class=ssagingservicesremotingadaptersJavaAdapter default=true/>
</adapters>
<defaultchannels>
<channel ref=myamf/>
</defaultchannels>
<destination id=login>
<properties>
<source>comLoginDemo</source>
</properties>
</destination>
</service>
mxml
Java代码
<?xml version= encoding=utf?>
<mx:Application xmlns:mx= layout=absolute>
<mx:Script>
<![CDATA[
import mxrpceventsFaultEvent;
import mxrpceventsResultEvent;
import ntrolsAlert;
[Bindable]
var returnValue:String;
var username:String;
var password:String;
function sendRequest():void{
username=usernametext;
password=passwordtext;
rovalidate(usernamepassword);
roaddEventListener(ResultEventRESULTresults);
}
function results(event:ResultEvent):void{
returnValue=eventresult as String;
}
function faultHandler(event:FaultEvent):void{
Alertshow(eventfaulttoString());
}
]]>
</mx:Script>
<mx:RemoteObject id=ro destination=login fault=faultHandler(event)>
</mx:RemoteObject>
<mx:Panel height= width= layout=absolute title=用户登录>
<mx:Label x= y= text=用户名 width=></mx:Label>
<mx:Label x= y= text=密码 width=></mx:Label>
<mx:TextInput id=username x= y=/>
<mx:TextInput id=password x= y=/>
<mx:Button x= y= label=登录 click=sendRequest()/>
<mx:Label x= y= text={returnValue}/>
</mx:Panel>
</mx:Application>