blazes简单例子.doc
上传人:sy****28 上传时间:2024-09-13 格式:DOC 页数:3 大小:26KB 金币:15 举报 版权申诉
预览加载中,请您耐心等待几秒...

blazes简单例子.doc

blazes简单例子.doc

预览

在线预览结束,喜欢就下载吧,查找使用更方便

15 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

已经在早前就听说了,Adobe公司的开源项目bazeds,可是当时做flash,用到了openamf,所以没有在意,但是现在觉得flex开发应用软件更具有杀伤力,所以准备研究flex。折腾了一周的时间想做个flex+java的helloworld例子,可是怎么都运行不出来,今天终于运行出来了。总结,共有一下几种方法:1,flex项目和web项目在同一项目。2,flex项目和web项目为两个项目,进行交互。个人认为,第二种比较好,这样可以完全将flex卡发和web业务开发分开。我这里也介绍第二种方法。下面介绍我的hello小程序。首先,开发环境1,eclipse3.2+myeclipse5.1,不多说2,eclipse的flex插件:FB3_WWEJ_Plugin.exe3,必须得到blazeds.war,网上很多,可以进行下载(附件中配备)下来,演示例子。1,创建web项目:我的项目是hello2,将blazeds.war放入tomcat中,启动,将blazeds.war项目中的,WebConten/Web-Inf复制3,替换hello项目(用刚才复制的将此项目(hello)中的替换)4,在web项目中建立java类Java代码packagecom.demo;publicclassHelloWorld{publicStringsayHello(Stringname){System.out.println(name);return"hello,"+name;}}packagecom.demo;publicclassHelloWorld{publicStringsayHello(Stringname){System.out.println(name);return"hello,"+name;}}5,在刚才复制的flex目录下打开remoting-config.xml,写入一下代码Xml代码<destinationid="Hello"><properties><source>com.demo.HelloWorld</source></properties></destination><destinationid="Hello"><properties><source>com.demo.HelloWorld</source></properties></destination>6,发布此项目。以上是web项目中的内容,下来看看flex项目1,创建flex项目,flexTest,applicationtype选择webapplication,servertechnology选择none,点next,outputfolder中选择你上面建立web工程的目录(这里就是hello),很多地方都说选择j2ee,这个是建立集成项目时候选择的。2,写入mxmlHtml代码<?xmlversion="1.0"encoding="utf-8"?><mx:Applicationxmlns:mx="http://www.adobe.com/2006/mxml"layout="absolute"><mx:Script><![CDATA[importmx.rpc.events.FaultEvent;importmx.rpc.events.ResultEvent;[Bindable]privatevarhelloResult:String;privatefunctionsayHello():void{ro.sayHello(inputText.text);}privatefunctionresultHandler(event:ResultEvent):void{helloResult=event.resultasString;}]]></mx:Script><mx:RemoteObjectid="ro"destination="Hello"result="resultHandler(event)"endpoint="/Hello/messagebroker/amf"/><mx:HBoxx="0"y="10"width="100%"><mx:Labeltext="Name:"id="nameLabel"/><mx:TextInputid="inputText"/><mx:Buttonlabel="sayHello"id="nameButton"click="sayHello()"/><mx:Labelid="resultLabel"text="{helloResult}"/></mx:HBox>