问题描述
就是一个很简单的heollword的例子 开始我能调用java方法 可是后来我怎么也调用不到java方法了。在此谢谢了但是我在别的机器上发布了 测试可以调用java方法 为什么我的机器不能。FirstJavaFlex.mxml 文件代码 <?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:Script> <![CDATA[ import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; import mx.controls.Alert; [Bindable] private var helloResult:String; private function sayHelloTo():void { Alert.show(inputText.text); zuo.sayHelloTo(inputText.text); } private function resultHandler(event:ResultEvent):void { helloResult = event.result as String; } ]]> </mx:Script> <mx:RemoteObject id = "zuo" destination = "first" result = "resultHandler(event)" /> <mx:HBox width = "100%" > <mx:TextInput id = "inputText" /> <mx:Button label = "Submit" click = "sayHelloTo()" /> <mx:Label text = "{helloResult}" width="300" height="69"/> </mx:HBox > </mx:Application> remoting-config.xml 文件代码<?xml version="1.0" encoding="UTF-8"?><service id="remoting-service" class="flex.messaging.services.RemotingService"> <adapters> <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/> </adapters> <default-channels> <channel ref="my-amf"/> </default-channels> <destination id="first"> <properties> <source>com.java.flex.FirstJavaFlex</source> </properties> </destination></service>java 类文件package com.java.flex;public class FirstJavaFlex {public String sayHelloTo(String name) {System.out.println("call java success!");return "welcome to JavaFlex world: " + name;}} 问题补充:yqin 写道
解决方案
<mx:RemoteObject id = "zuo" destination = "first" result = "resultHandler(event)" /> 加上endpoint属性endpoint="http://localhost:8080/Flex_J2ee/messagebroker/amf"