最先下载FlashBuilder_4_7_LS10_win64.exe试了几个eclipse安装插件都没成功,包括myeclipse8.5、spring sts2.9.2、eclipse3.5、j2eeeclipse版本4.2.0,后来搞了一个FlashBuilder_4_LS10.exe安装完找不到插件安装文件原来这个是单独版,必须插件版才行,最后下载FlashBuilder_4_Plugin_LS10.exe终于配置成功了,myeclipse8.5不行,spring sts可以了。

spring sts部署应用跟myeclipse不一样,比较类似eclipse。

用sts整合flex和java有几个步骤:

1:新建动态web工程flexweb,创建web.xml

2: blazeds-turnkey-4.0.0.14931.zip解压, 复制blazed两个文件夹flex和lib到WEB-INF下,里面是blaze的jar包和flex配置文件,然后修改web.xml加入blaze支持

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<listener>
  <listener-class>flex.messaging.HttpFlexSession</listener-class>
 </listener>
 
 
 <!-- MessageBroker Servlet -->
 <servlet>
  <servlet-name>MessageBrokerServlet</servlet-name>
  <servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
  <init-param>
   <param-name>services.configuration.file</param-name>
   <param-value>/WEB-INF/flex/services-config.xml</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
  <servlet-name>MessageBrokerServlet</servlet-name>
  <url-pattern>/messagebroker/*</url-pattern>
 </servlet-mapping>

3:项目右键,添加/更改项目类型>添加flex类型项目,第一步,应用程序类型选择J2EE,下方选择BlazeDS,第二部根文件夹填入项目在workspase的路径加一个WebContent,如E:\workspaces\sts\flexweb\WebContent,根URL填http://localhost:8080/flexweb,上下文根目录/flexweb,输出文件夹使用默认E:\workspaces\sts\flexweb\WebContent\flexweb-debug,点击finish
4:转换完成后,目录有些变化,右键项目>properties>flex构建路径,主源文件夹改为flex_src,然后把自动生成的src目录下的flexweb.mxml移动到flex_src下,环境搭建就算完成了

HelloWorld

flexweb.mxml:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?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="955" minHeight="600"
 
 <fx:Script
  <![CDATA[ 
   import mx.controls.Alert; 
   import mx.rpc.events.ResultEvent; 
   
   protected function myFlex_resultHandler(event:ResultEvent):void{ 
    var name:String=event.result as String; 
    Alert.show(name); 
   
   protected function button1_clickHandler(event:MouseEvent):void 
   {  
    myFlex.sayHello(txtName.text); 
   
  ]]>
 </fx:Script
 
 <fx:Declarations
  <!-- 将非可视元素(例如服务、值对象)放在此处 -->
  <s:RemoteObject id="myFlex" destination="mytest" result="myFlex_resultHandler(event)"/> 
 </fx:Declarations
 <s:Button x="209" y="135" label="按钮" click="button1_clickHandler(event)"/> 
 <s:TextInput x="166" y="81" id="txtName"/> 
 <s:Label x="10" y="81" text="请输入内容:" fontSize="15" fontWeight="bold" fontFamily="中易黑体"