谁能大致的解释下下面的flex代码?thank you!<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:RemoteObject destination="com.yeeach.HelloWorldService" id="helloWorldService">
<mx:method name="hello" result="sayHelloResult(event)"/>
<mx:method name="world" result="sayWorldResult(event)"/>
</mx:RemoteObject>
<mx:HBox>
<mx:Label text="输入:"/>
<mx:TextInput id="inputStr"/>
<mx:Button label="say hello" click="sayHello(event);"/>
<mx:Button label="say world" click="sayWorld(event);"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="结果:"/>
<mx:TextArea id="result"/>
</mx:HBox> 

<mx:Script> 
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent; 

function sayHello(event:Event):void
{
var inputVar:String=inputStr.text;
helloWorldService.hello(inputVar); 


function sayWorld(event:Event):void
{
var inputVar:String=inputStr.text;
helloWorldService.world(inputVar); 


private function sayHelloResult(event:ResultEvent):void
{
result.text=event.result.toString();
Alert.show(event.result.toString(), "返回结果");


private function sayWorldResult(event:ResultEvent):void
{
result.text=event.result.toString();
Alert.show(event.result.toString(), "返回结果");
}
]]>
</mx:Script>
</mx:Application>

解决方案 »

  1.   

    就是flex以RemoteObject的方式调用了(HelloWorldService)后台代码,然后显示返回的数据。
      

  2.   

    <mx:method name="hello" result="sayHelloResult(event)"/>
    <mx:method name="world" result="sayWorldResult(event)"/><mx:Button label="say hello" click="sayHello(event);"/>
    <mx:Button label="say world" click="sayWorld(event);"/>主要是这四句代码怎么理解
      

  3.   

    HelloWorldService.hello();
    返回结果的方法:sayHelloResult
    HelloWorldService.world();
    返回结果的方法:sayWorldResult
    两个button 点击事件
      

  4.   

    sayHello-(com.yeeach.HelloWorldService内的方法world)helloWorldService.world-sayHelloResult
      

  5.   

    点击Button,触发click事件,调用click定义的事件处理方法(sayHello或sayWorld方法),事件处理方法再调用helloWorldService中的方法,service方法执行完毕后,调用result中定义的返回结果处理方法(sayHelloResult或sayWorldResult)。