Right now I'm trying to understand how Flex works with Java (Flex -> BlazeDS -> Java). I tried to follow THIS tutorial and everything works fine, I just don't understand why do we need to call java function this way:
<mx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
// Send the message in response to a Button click.
private function echo():void {
var text:String = ti.text;
remoteObject.echo(text);
}
// Handle the recevied message.
private function resultHandler(event:ResultEvent):void {
ta.text += "Server responded: "+ event.result + "\n";
}
// Handle a message fault.
private function faultHandler(event:FaultEvent):void {
ta.text += "Received fault: " + event.fault + "\n";
}
]]>
</mx:Script>
Why do we need to use Event/ResultEvent in order to call Java function. Why not just to do something like this:
EchoService.echo("hi")
Thanks