用flex+BlazeDS做前端开发web入门小例

一,到http://opensource.adobe.com/wiki/display/blazeds/Downloads下载一个blazeds-turnkey-4.x.x.x.zip包

 

二,打开Myeclise8.0新建一个javaweb工程,选择javaEE 5.0如图

 

三,右击WebRoot选择import->General->File system,导入BlazeDS中的文件(导入前先解压blazeds.war包)

 

四,将flexweb部署到tomcat中

 

五,在flex builder中新建一个Flex项目flexweb

 

六,下一步配置你的服务器路径

 

七,在myeclipse项目中

package test;

public class Accptech {
 public String helloWorld(String message) {
  
  return message+", welcome to back!";
 }                     
}

 

八,配置Webroot/WEB-INF/flex/remoting-config.xml

<destination id="mytest">
    <properties>
        <source>test.Accptech</source>
    </properties>
 </destination>

 

九,在flex项目的flexweb .mxml中

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="1024" minHeight="768">
	
	<fx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import mx.rpc.events.FaultEvent;
			import mx.rpc.events.ResultEvent;
			protected function myFlex_resultHandler(event:ResultEvent):void
			{
				var name:String=event.result as String;
				Alert.show(name);
			}
			
			protected function btnSend_clickHandler(event:MouseEvent):void
			{
				myFlex.helloWorld(txtName.text);
			}
		]]>
	</fx:Script>
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
		<s:RemoteObject id="myFlex" destination="mytest" result="myFlex_resultHandler(event)"  />
	</fx:Declarations>
	<s:Panel x="87" y="20" width="250" height="200" title="www.accptecg.com flex4">
		<s:TextInput x="16" y="37" id="txtName"/>
		<s:Button x="168" y="38" label="发送" id="btnSend" click="btnSend_clickHandler(event)"/>
	</s:Panel>

</s:Application>


十,启动tomcat,在flex项目中运行flexweb.mxml

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值