flex java整合

來源:互聯網
上載者:User

[聲明:著作權歸原創所有http://hi.baidu.com/duqian1985/blog/item/bb3bdf062fe95a73020881dd.html]

step 1.下載 flex 3.0 plugin 外掛程式 裝在 我的myeclipse 6.0 上

   1) :http://trials.adobe.com/Applications/Flex/FlexBuilder/3/FB3_WWEJ_Plugin.exe

   2)安裝外掛程式

    將flex plugin 安裝目錄裡面的com.adobe.flexbuilder.update.site 檔案夾下面的features 檔案夾,plugins 檔案夾 和 site.xml 檔案 添加在myeclipse 檔案夾的eclipse檔案夾內.

              將 flex plugin 安裝目錄裡面的eclipse 檔案夾下面的features 檔案夾,plugins 檔案夾 覆蓋在myeclipse 檔案夾的eclipse檔案夾內.(防止更新)

step1 完

 

step 2.下載 blazeds  

http://download.macromedia.com/pub/opensource/blazeds/blazeds_bin_3-0-0-544.zip

解壓之後是個 blazeds. war包,把它放在tomcat 的webapp裡面 部署一下就會釋放出來一個類似與工程檔案的東西(裡面就有將flex 和java 合并的重要檔案)

step 2 完

step 3 . 合并 web project 和flex 工程

建立一個web project 工程

把 blazeds.war 部署之後的 flexweb 檔案夾裡面的lib 目錄copy 到 web-inf 的lib目錄裡

把 blazeds.war 部署之後的 flexweb 檔案夾裡面的flex 目錄copy 到 web-inf 下面

替換 web.xml 這步很重要,容易忘記,忘記你就死定了,慢慢調去吧!

都加完了把? 這時候把web project 工程部署在tomcat上面上他跑起來, 之後在加入flex ,單擊工程右鍵flex project natrue --- > add flex project natrue

第一步見

 

第二步見

 

都整完了看一下配置是否正確,正確就可以進行 step 4了。

step 3 完


step 4 . 讓flex調用java類(這tm才是我們想要到達的目的!)

在src 裡面見一個包,包裡面見一個類 包名.類名 whatever

開始配置 remoting-config.xml

在裡面加入

    <destination id="hello">
         <properties>
             <source>com.Hello</source>
        </properties>
    </destination>

hello 是別名

com.hello 是類的全路徑

然後配置services-config.xml(這個tm那個介紹配置上面也沒寫,你說你到是告訴一聲啊,向我們這種粗心大意的人那在乎啊,就因為這個沒配置我就浪費了2個小時,我只能對那些網上發文章教人家配置的大牛們,說一聲:"大哥在說的詳細點被")

        <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://127.0.0.1/flexweb/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint" />
    
        </channel-definition>

        <channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
            <endpoint url="https://127.0.0.1/flexweb/messagebroker/amfsecure " class="flex.messaging.endpoints.SecureAMFEndpoint"/>
            <properties>
                <add-no-cache-headers>false</add-no-cache-headers>
            </properties>
        </channel-definition>

        <channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://127.0.0.1/flexweb/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
            <properties>
                <polling-enabled>true</polling-enabled>
                <polling-interval-seconds>4</polling-interval-seconds>
            </properties>
        </channel-definition>

主要就是把那個 url 改成自己的工程 路徑,太tm 重要了!

step 4 完


使用 :

寫一個hello類

public class Hello {
    public String hello(String name){
        System.out.println(name);
        return "hello"+name;
    }
}

一個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.ResultEvent;
function gg(evnet:ResultEvent):void{
var ff:String = evnet.result as String;
ggg.text = ff;
}
function remotingSayHello():void{
var sname:String = nameInput.text;
h.hello(sname);
}
]]>
</mx:Script>
<mx:RemoteObject destination="hello" id="h"
result="gg(event)" endpoint="http://127.0.0.1/flexweb/messagebroker/amf" >
</mx:RemoteObject>
<mx:TextArea id="ggg" x="109" y="122"/>
<mx:Button label="say hello" click="remotingSayHello();" x="144" y="193"/>
<mx:TextInput id="nameInput" x="109" y="73"/>
<mx:Label text="name" x="47" y="75"/>
</mx:Application>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.