Flex的remoteObject例子
假设项目名称为:FlexWeb1、 创建项目时设置flex 的output为:FlexWeb -debug2、 在项目---〉Properties --à Flex server中设置Context root为:FlexWeb;和Root URL中后面 部分一样。3、 在项目---〉Properties --à Flex Compiler中Flex SDK Version 设置为: Use a specific SDK: Flex3.24、 创建Java类package com.remote; public class JavaRemote { public String doSomeThing(){ return "调用RemoteObject成功!";}}5、在WebContent/WEB-INF/flex/remoting-conffig.xml配置文件中增加: <destination id="javaRemote "> <properties> <source>com.remote.JavaRemote </source> </properties> </destination>6、在mxml中使用javaRemote <?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; private function showRemote(event:MouseEvent):void{ myFlex.doSomeThing(); } private function myFlex_resultHandler(event:ResultEvent):void{ var name:String=event.result as String; Alert.show(name); } ]]></mx:Script> <mx:RemoteObject id="myFlex" destination="javaRemote" endpoint="http://localhost:8080/FlexWeb/messagebroker/amf" result="myFlex_resultHandler(event)" /> <mx:Button id="btShow" label="测试" click="showRemote(event)" /> </mx:Application>
?