网上都是一堆RemoteObject的标签例子,很少有用as代码写的 自己试着写了个例子,放在这里,人老了很多东西都记不住那么全 package { import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.rpc.events.ResultEvent; import mx.rpc.remoting.mxml.RemoteObject; public class RemoteObjectTest extends mx.rpc.remoting.mxml.RemoteObject //继承RemoteObject(标签或类都行) { public function RemoteObjectTest() { this.destination = "helloWorld"; //设置与java配置文件remote-config.xml中相同的id this.source = "com.blaze.test.Test"; //与配置文件中相同的source this.addEventListener(ResultEvent.RESULT,handleComplete);//加载监听程序 } public function getHelloWorld():void { getOperation("getHelloWorld").send();//调用java中的方法,传入java方法名字的字符串 } public function handleComplete(event:ResultEvent):void { var a:ArrayCollection = event.result as ArrayCollection; //根据返回的数据类型将event.result格式化成flex的响应类型 var s:String = new String(); for(var i:String in a) { s += i; } Alert.show(s); } } }