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>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值