flex通信
来源:互联网 发布:全球进出口贸易数据 编辑:程序博客网 时间:2024/05/16 03:49
环境:eclipse 3.5 + tomcat 6.0 + flex builder 3.0 + blazeds-turnkey-3.2.0.3978.zip(adobe网站上下载)
(因为不能放截图所以只能叙述了)
1,新建一个java web项目 例名为 :testjava;
2,在此工程中写一个简单的类:
package cn.com;
public class InfoTest {
public String seeHello() {
return "Hello World";
}
}
3,在testjava工程加与flex通信环境:
解压blazeds-turnkey-3.2.0.3978.zip,找到里面的blazeds.war,将它导进testjava工程(右击WebContent>>import...>>File System 选上硬盘中你的blazeds.war地址>>finish)
编辑WEB-INF/flex/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="InfoTest ">//这个与flex 中的RemoteObject对应
<properties>
<!-- 写上完整的与flex通信的类名(包名+类名) -->
<source>cn.com.InfoTest </source>
</properties>
</destination>
</service>
再编辑web.xml:
4,将工程部署到tomcat上,并启动
5,在flex builder 中建一个flex project (名为testflex)
注意界面选项:a. Application type 选择 Web application(runs in Flash Player)
b. Server technology:
Application server type 选择J2EE 点next
c. Server location:
Root folder:选上testjava工程的地址(如 D:/project/testjava/WebContent)
Root URL:写上testjava工程的访问路径(如 “http://localhost:8080/testjava”)
Context root: testjava(web工程名)其余的不用动直到finish
6,编辑testflex中的testflex.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.controls.Alert;
import mx.rpc.events.ResultEvent;
private function resultHandler(event:ResultEvent):void {
Alert.show(event.result.toString(), "连接成功");
}
private function faultHandler(event:FaultEvent):void {
Alert.show(event.fault.toString(), "连接失败");
}
]]>
</mx:Script>
<!-- destination 属性值就是testjava中 remoting-config.xml 中 destination 的 id -->
<mx:RemoteObject id="remoteObject"
destination="InfoTest "
result="resultHandler(event)"
fault="faultHandler(event)"/>
<mx:Button label="连接testjava" click="remoteObject.seeHello()" x="256.5" y="197"/>
</mx:Application>
7,最后选中testflex.mxml运行(Run Application) 即可
若无效果出现.....get flash,则你可用firefox查看效果试试(将flex开发工具属性中的的Web Browser选为firefox,并把flex--Profiler--Player/Browser 中配置flashPlay用firefox的exe文件)
- flex通信
- flex与xml通信
- Flex module 通信。
- Flex与WebService通信
- flex 和php 通信
- Flex 与 servlet 通信
- FLEX与HttpService通信
- java与flex通信
- Flex的通信方式
- Flex Javascript 通信
- Flex Socket通信
- Flex与服务器端通信
- Flex与java通信
- Flex与java通信
- flex的Socket通信
- Flex和java通信
- C++与Flex通信
- flex的Socket通信
- 从零开始学Java (一)
- 接口和抽象类的区别
- Java 中两种ftp操作方式
- 注册信息验证程序源码
- js打开网页总结
- flex通信
- Android学习基础要点总结
- 【转】程序员相关的笑话 - 陈皓专栏 【空谷幽兰,心如皓月】 - CSDN博客
- 白话Ajax
- 写程序写的女友都走了
- 持续改进思考能力才是思考的核心竞争力
- 2010星城事
- 好书大全!!!!
- 必须掌握的八个【cmd 命令行】