【important】FLEX Blazeds 环境搭建
JDK15
tomcat6
MyEclipse6 + Flex sdk3.2
Blazeds turkey
1. MyEclipse中创建Web项目ServerTest
2. 导入Blazeds相关Jar, web.xml 还有 WEB-INF 下flex目录中的所有文件。
最简单的办法: 加压blazeds.war 文件,在新建的工程的WebRoot目录上右键 import-> File System->next 选择解压后的blazeds目录, finish。 这样会提示是否覆盖,yes to all 就OK了。
3. 服务器端代码:
package com.test; public class HelloWorld { public String sayHello(String name) { return "hello," + name; } }
在WebRoot/WEB-INFO/remoting-config.xml中加入id="Hello"的destination
<destination id="Hello"> <properties> <source>com.test.HelloWorld</source> </properties> </destination>
可以部署到tomcat了,并且启动tomcat,这个时候不要着急着去测试
4. Flex工程的搭建
建flex工程,输入工程的名称flexTest,application type 选择 web application,
server technology 选择none,
点next,
output folder 中选择你上面建立web工程的目录(这里就是ServerTest了)
Flex代码:
<?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; [Bindable] private var helloResult:String; private function sayHello():void { ro.sayHello(inputText.text); } private function resultHandler(event:ResultEvent):void { helloResult = event.result as String; } ]]> </mx:Script > <mx:RemoteObject id="ro" destination="Hello" result="resultHandler(event)" endpoint="/myflex/messagebroker/amf"/> <mx:HBox x="0" y="10" width="100%"> <mx:Label text="Name:" id="nameLabel"/> <mx:TextInput id="inputText"/> <mx:Button label="say Hello" id="nameButton" click="sayHello()"/> <mx:Label id="resultLabel" text="{helloResult}"/> </mx:HBox> </mx:Application>
参照自:
http://hi.baidu.com/ecspell/blog/item/ada556e7e006f22bb8382043.html
浙公网安备 33010602011771号